Questions tagged [nsmutabledictionary]

NSMutableDictionary is the mutable version of NSDictionary.

Like NSDictionary (), it is a subclass of NSObject (), that allows you to have a collection of objects, but instead of having them stored in an array retrievable by their index, they are stored as a key-value pair. Each object stored in an NSDictionary can be retrieved by a unique key assigned to it. Keys have to be unique and can be any object as long as they adopt the NSCopying protocol – they are usually an instance of NSString ().

Neither a key nor the object paired with it can be nil, however, you may use NSNull for storing null objects.

If two objects are stored with the same key, the first one is released, and the last one is stored.

When using key-value coding, the key must be a string. When using key-object coding, the key is copied using copyWithZone: and it must conform to the NSCopying protocol. This object is retained, rather than copy.

NSMutableDictionary gives you the ability to modify this set of key-object paired collection without having to empty it and refill it again as a whole set. The following methods are for this purpose:

Adding Entries to a Mutable Dictionary

– setObject:forKey: 
– setValue:forKey: 
– addEntriesFromDictionary: 
– setDictionary:

Removing Entries From a Mutable Dictionary

– removeObjectForKey: 
– removeAllObjects 
– removeObjectsForKeys:

Resources:

1306 questions
-2
votes
1 answer

Sort NSMutableDictionary keys by Value of type NSDate

I have a NSMutableDictionary named LogDateMsg. In this dictionary I am storing NSDate objects as values for which the key is of type long. I need to sort my keys in the descending order based on the date value they have. I am using the below code…
Exception
  • 2,273
  • 1
  • 24
  • 42
-2
votes
2 answers

How to Sort NSMutableDictionary in iOS

I am new to iOS development. I am creating NSMutableDictionary with Title, Count, Score. Now I want to sort my NSMutableDictionary with the base of Count in Descending order. Please help me. self.top3_Question_Array = [[NSMutableArray alloc]…
SHIDHIN TS
  • 1,557
  • 3
  • 26
  • 58
-2
votes
2 answers

iOS 9.0 - NSMutableDictionary causing EXC_BAD_ACCESS

My application includes a singleton class represents general data. The latter contains the following atomic property : // .h file @property (atomic, strong) NSMutableDictionary *dataDictionary; // .m file @synthesize dataDictionary; The dictionary…
Tsahi Deri
  • 571
  • 1
  • 3
  • 14
-2
votes
2 answers

NSMutableDictionary with key:string and value:

I'm a noob to objective-c and I'm trying to create a dictionary with key:string and value:.
user235236
  • 447
  • 1
  • 5
  • 16
-2
votes
2 answers

sort array specified indexes IOS

I' want to filter NSARRAY based on an object named id, I've specific set of Ids that I want to filter and want to be first in NSARRAY. I stored the following Ids as NSNUMEBR NSNumber *A = [NSNumber numberWithInt:1122]; NSNumber *B…
developer
  • 668
  • 1
  • 6
  • 24
-2
votes
2 answers

NSMutableDictionary Literal

CLBeaconRegion *region; NSMutableDictionary *beacons; .... beacons[region] = beacons; Is the code above setting beacons key as region to the value of beacons? I thought the key has to be a string in a NSDictionary/NSMutableDictionary?
user1107173
  • 10,334
  • 16
  • 72
  • 117
-2
votes
1 answer

insert object in an NSMutableArray with NSmutableDictionary in UserDefaults

I have an NSMutableArray. The array is storing NSMutableDictionary. The dictionary object is storing NSUserDefault values. These are slider values previously selected by user. Now I want that, when user move these sliders then new slider values must…
-2
votes
3 answers

How to save object in NSMutableDictionary

I want to assign a object to NSMutableDictionary in one method and want to use it in another method as below: - (void) aaa { NSString* aa = @"hello"; [self.pcs setObject:aa forKey:@"a"]; } - (void) bbb { NSLog(@"ccc %@", self.pcs[@"a"]); }…
Yong
  • 738
  • 6
  • 19
-2
votes
1 answer

adding an NSMutableArray to NSMutableDictionary

I am trying to add NSMutableArray's to a NSMutableDictionary My code looks something like this: [myDictionary setObject:[NSMutableArray array] ForKey: myKey]; [[myDictionary objectForKey:myKey] addObject: myString]; So what I am trying to do: I…
-2
votes
3 answers

id to int conversion from NSMutableDictionary to NSArray

I'm loading numbers from a .plist file, with values of either 0 or 1. I then load these values into an NSArray. Then I want to be able to do if([levelOkays[1] == 1){ [play1 setTitle:@"Play" forState:UIControlStateNormal]; [play1…
Schwaitz
  • 473
  • 3
  • 12
-2
votes
1 answer

How can i assign value of nsmutable array which is inside of nsmutable dictionary into another nsmutable dictionary

How can i assign value of nsmutable array which is inside of nsmutable dictionary into another nsmutable dictionary or NSDictionary? NSMutableDictionary *readers = [[NSMutableDictionary alloc] init]; [readers setObject:[[NSMutableArray alloc]…
Jan
  • 1,744
  • 3
  • 23
  • 38
-2
votes
3 answers

Objective-C: 'unrecognized selector sent to instance'

I want to set the value of an object for a certain key, but I get this strange error. I also tried to use setValue instead of setObject and the routenArray2 also got the key in it. NSMutableArray *routenArray = [[NSMutableArray alloc]…
-2
votes
2 answers

ios sort a mutable dictionary order

I saw many examples on SO but I'm not sure if it applies to this situation. Everywhere it says NSMutableDictionries are not guaranteed an order...but I'm getting my data from the server...so my NSMuteDic looks like this: { joe = ( …
denikov
  • 877
  • 2
  • 17
  • 35
-2
votes
3 answers

NSMutableDictionary issues

I'm trying to insert an object in my dictionary, but first, I want to test if it's a NSMutableDictionary : if ([[[self.response objectForKey:@"X"] objectAtIndex:0] isKindOfClass:[NSMutableDictionary class]]) { [[[self.response…
Nabil El
  • 972
  • 1
  • 10
  • 24
-2
votes
4 answers

NSMutableDictionary to tableview cell

NSString* path = @"http://username:apicode@flightxml.flightaware.com/json/FlightXML2/AirlineFlightSchedules?startDate=1394424000&endDate=1394486000&origin=KLAX&destination=KJFK&airline=UAL&howMany=10&offset=0"; NSMutableURLRequest* _request =…