nsmutabledictionary

Using one setter for all model iVars

↘锁芯ラ 提交于 2019-12-04 05:35:38
问题 I have a series of models for my application. Across all these models there are (will be) some 200 or 300 instance variables. The application stores its persistent data on a web-based server (MySQL - but I guess that part doesn't matter). Whenever a model iVar is updated I need to make a call to the server to update the appropriate value for that iVar. My current model strategy is (header file): @interface MyModel : NSObject { NSString * firstName; NSString * lastName; } @property (readwrite,

Issues using NSIndexPath as key in NSMutableDictionary?

99封情书 提交于 2019-12-04 03:34:35
Is there any particular reason why attempting to store and retrieve a value in an NSMutableDictionary using an NSIndexPath as a key might fail? I originally attempted to do this in order to store an NSMutableDictionary of UITableViewCell heights ( self.cellHeights ) for a UITableView . Each time you tapped a UITableViewCell , that cell would either expand or contract between two different heights based on the value stored in the NSMutableDictionary for that particular indexPath : - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSNumber

NSMutableDictionary with UIButton* as keys - iPhone development

ε祈祈猫儿з 提交于 2019-12-04 03:09:37
I'm new to iPhone development and I have a question that may have a very simple answer. I am trying to add buttons to a view and these buttons are associated with a custom class that I defined. When I add the buttons to the view, I would like to know what class these buttons correspond to. This is because when I press the button, I need to get some information about the class, but the receiver of the message is another class. I couldn't find information about an error that I'm getting on the web. The problem I have is that I'm trying to create an NSMutableDictionary where the keys are of type

[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance

瘦欲@ 提交于 2019-12-04 02:50:33
问题 I am trying to add "dateTime" to My dictionary as defined follows: Symptom Ranking: { 5111ef19253b4a9150000000 = 1; 5111f029253b4add4e000000 = 1; 5111f036253b4a123d000001 = 1; 5111f045253b4a404f000000 = 1; } NSLog(@"date selected: %@", [[self.datePicker date] description]) [self.results setObject:[[self.datePicker date] description] forKey:@"dateTime"]; App crashes and I get this: Symptom Tracker[43134:c07] -[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance 0x7603990

how to change order of NSMutable array in same way another mutable arrays get changed

徘徊边缘 提交于 2019-12-04 02:35:26
问题 I have three arrays . They are name , birthdates and remaining days like below: name birthdate remaining "Abhi Shah", "01/14", 300 "Akash Parikh", "12/09/1989", 264 "Anand Kapadiya", "12/01", 256 "Annabella Faith Perez", "03/02", 347 "Aysu Can", "04/14/1992", 25 "Chirag Pandya" "10/07/1987" 201 I want to rearrange the remaining days array into ascending order, but at the same time name and birthdate should also get reordered in the same way. See this example below: name birthdate remaining

iPhone: Not able to store NSMutableDictionary to NSUserDefaults

独自空忆成欢 提交于 2019-12-03 22:17:30
I am trying to implemen "Add to Favorites" functionality using NSMutableDictionary as I have to add multiple key-values. The following addToFavourites method always display Count=0 even after adding object to dictionary. I read this and getting nsdefaults into mutabledictionary(instead of mutable array) and setting resulted dictionary back to nsdefaults but not sure what's the problem. Any help would be really appreciated. Thank you. Edited: From this I came to know that I have to move data around mutable and immutable dictionary and then it worked fine! but still not able to synchronize

Why does NSUserDefaults fail to save NSMutableDictionary?

半腔热情 提交于 2019-12-03 21:39:56
问题 I’m trying to save a NSMutableDictionary with NSUserDefaults . I read many posts on the topic in stackoverflow... I also found one option that worked; however unfortunately it worked only once and then it started to save (null) only. Does anybody have a hint? Thanks Code to save: [[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:dictionary] forKey:@"Key"]; [[NSUserDefaults standardUserDefaults] synchronize]; Code to load: NSMutableDictionary

Subclassing NSMutableDictionary

拈花ヽ惹草 提交于 2019-12-03 16:42:48
问题 I am trying to implement a subclass of NSMutableDictionary that returns nil instead of throwing a NSUndefinedKeyException when the key is not present in the Dictionary. However when I try to add objects to my dictionary I get [NSMutableDictionary setObject:forKey:]: method only defined for abstract class NilDictionary.h @interface NilDictionary : NSMutableDictionary { } @end NilDctionary.m @implementation NilDictionary - (id)valueForUndefinedKey:(NSString *)key { return nil; } @end Do I

Add values in NSMutableDictionary in iOS with Objective-C

这一生的挚爱 提交于 2019-12-03 15:41:40
问题 I'm starting objective-c development and I would like to ask the best way to implement a list of keys and values. In Delphi there is the class TDictionary and I use it like this: myDictionary : TDictionary<string, Integer>; bool found = myDictionary.TryGetValue(myWord, currentValue); if (found) { myDictionary.AddOrSetValue(myWord, currentValue+1); } else { myDictionary.Add(myWord,1); } How can I do it in objective-c ? Is there equivalent functions to the above mentioned AddOrSetValue() or

Cocoa's NSDictionary: why are keys copied?

随声附和 提交于 2019-12-03 11:02:11
问题 All objects used as keys in NS(Mutable)Dictionaries must support the NSCopying protocol, and those objects are copied when they're used in the dictionary. I frequently want to use heavier weight objects as keys, simply to map one object to another. What I really mean when I do that is effectively: [dictionary setObject:someObject forKey:[NSValue valueWithPointer:keyObject]]; ("When I come back and hand you this same key object instance again, get me that same value out.") ...which is exactly