nsmutabledictionary

How to remove elements in NSMutableArray or NSMutableDictionary during enumeration?

一曲冷凌霜 提交于 2020-01-10 23:41:30
问题 I am using block based enumeration similar to the following code: [[[rows objectForKey:self.company.coaTypeCode] objectForKey:statementType] enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id coaItem, NSUInteger idx, BOOL *stop) { // block code here }] I would like to remove some of the objects during the enumeration process depending on the their object values. How could I do this? I know that manipulating an mutable array or dictionary (NSMutableArray or NSMutableDictionary

Observing NSMutableDictionary changes

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-09 13:12:45
问题 Is it possible to observe (subscribe to) changes to values stored under different keys in an NSMutableDictionary? In my case the keys would already exist when the subscription is initiated, but the values change and I would like to be notified in this case. I would like the key of the changed value in the notification. I assume that if my dictionary keys were all NSString instances I could just subscribe to each key path individually. But what if my keys are non-strings? Am I out of luck in

NSDictionary: Find a specific object and remove it

混江龙づ霸主 提交于 2020-01-07 05:27:05
问题 I have NSMutableDictionary that looks like this: category = ( { description = ( { id = 1; name = Apple; }, { id = 5; name = Pear; }, { id = 12; name = Orange; } ); id = 2; name = Fruits; }, { description = ( { id = 4; name = Milk; }, { id = 7; name = Tea; } ); id = 5; name = Drinks; } ); Now, when a user performs an action in my application, I get the @"name"-value of the object, like "Apple". I would like to remove that object from the dictionary, but how will can I reach this object with

How to compare two dictionary key values and print text in cell in iOS?

做~自己de王妃 提交于 2020-01-06 18:30:33
问题 I have two dictionary with multiple items. I want to compare values. Dict1:{ "Displacement_trim" = "49.26 "; "Dry_Weight" = "<null>"; } Dict2:{ "Displacement_trim" = "171.20 "; "Dry_Weight" = "<null>"; } I want to know which "Displacement_trim" is greater. Also checking null values. Print the data in cell. How can I achieve this? 回答1: To find out which value from the dict is bigger use the following code: Swift 3 let dict1 = [ "Displacement_trim" : "49.26", "Dry_Weight" : "<null>" ] let dict2

iOS - Add NSDictinary key values into an NSArray sequencialy

旧街凉风 提交于 2020-01-05 21:12:21
问题 I have a NSDictionary and a NSArray : self.dataDic = [[[NSDictionary alloc] init] autorelease]; self.dataDicKey = [[[NSArray alloc] init] autorelease]; These are the key and value of my NSDictionary : self.dataDic = @{@"Ring Cloud" :@[@"Contact Cloud", @"Image Cloud", @"Data Cloud"], @"Ring Tools" :@[@"Sticker Market", @"Live Poll", @"Mail"], @"Ring Apps" :@[@"Studio", @"Player"]}; Now what I want is to insert all the key value of my self.dataDic into self.dataDicKey sequentially. That means

iOS - Add NSDictinary key values into an NSArray sequencialy

我是研究僧i 提交于 2020-01-05 21:09:32
问题 I have a NSDictionary and a NSArray : self.dataDic = [[[NSDictionary alloc] init] autorelease]; self.dataDicKey = [[[NSArray alloc] init] autorelease]; These are the key and value of my NSDictionary : self.dataDic = @{@"Ring Cloud" :@[@"Contact Cloud", @"Image Cloud", @"Data Cloud"], @"Ring Tools" :@[@"Sticker Market", @"Live Poll", @"Mail"], @"Ring Apps" :@[@"Studio", @"Player"]}; Now what I want is to insert all the key value of my self.dataDic into self.dataDicKey sequentially. That means

Can we use NSMutable objects as members of a non-NSMutable class

守給你的承諾、 提交于 2020-01-05 03:25:19
问题 Suppose we have simple NSDictionary class, can one of its objects be an NSMutableDictionary object? When we edit a value within the NSMutableDictionary object, we are only editing values of the object of NSDictionary . Since we are not editing the object of NSDictionary , should it be a problem for the non-mutable NSDictionary class? 回答1: The mutability of a collection class refers only to the ability to modify the collection as a whole, not the members. The collection in fact just consists

objective c when to use NSDictionary instead of NSArray [duplicate]

▼魔方 西西 提交于 2020-01-04 07:49:26
问题 This question already has answers here : What's the difference between a dictionary and an array? (6 answers) Closed 6 years ago . I'm in a dilemma in terms of which of the two I should use. I will be retrieving a group of data via a restful API (returns json) and I'm not sure how I should store them before I display it on my UI View Table. eg. {"Events":[{"Id":5,"Name":"Event 1 2013"},{"Id":6,"Name":"Event 2 2013"}]} I've been reading tutorials and some would use NSMutableArrays while some

How to load an NSDictionary from a file created with writeToFile?

可紊 提交于 2020-01-04 03:01:16
问题 I have an NSMutableDictionary, and I wrote it using [stuff writeToFile:@"TEST" atomically:YES]; How can I retrieve it in the future? Also, what would happen if I decide to replace my iPhone 4 with the 4S? Can my piece of written data be transferred? 回答1: I think you want something like: [[NSMutableDictionary alloc] initWithContentsofFile:[self dataFilePath]]; You do need to obtain the correct path to store and retrieve your file, along the lines of this routine: - (NSString *)dataFilePath {

How to get the value for each key in dictionary in Objective-C?

寵の児 提交于 2020-01-01 23:57:31
问题 I'm maintaining a NSMutableDictionary which holds key and value pair.Now i need to perform some operation for each value in it.How to retrive value from dictionary. // this is NSMutableDIctionary NSMutableDictionary *dictobj = [[NSMutableDictionary alloc]init]; // in methodA -(void)methodA { //get the value for each key and peform an operation on it. } How to proceed? plz help 回答1: for (id key in dictobj) { id value = [dictobj objectForKey:key]; [value doSomething]; } 回答2: I'm not entirely