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
-1
votes
3 answers

No visible @interface for 'NSMutableDictionary' declares the selector 'addObjects:forKey'

My code gives an error saying No visible interface for 'NSMutableDictionary' declares the selector 'addObjects:forKey:' .h @interface ViewController : UIViewController{ NSMutableDictionary…
-1
votes
2 answers

Why would my NSMutableDictionary be nil?

I am trying to store an array in a NSMutableDictionary. However the NSMutableDictionary is null after i have set objects to it. Here is my code any help is appreciated: NSMutableArray *arrTemp = [[NSMutableArray alloc] init]; NSMutableDictionary…
JH95
  • 489
  • 1
  • 7
  • 24
-1
votes
3 answers

How to modify an NSMutableDictionary using setValue or setObject?

In the header file: @property (strong, nonatomic) NSMutableArray *vocabs; @property (strong, nonatomic) NSMutableDictionary *vocab; in the .m file: -(void) loadFile { NSString* filepath = [[NSBundle mainBundle]pathForResource:@"vocabs"…
tipsywacky
  • 3,374
  • 5
  • 43
  • 75
-1
votes
2 answers

NSMutableDictionary data not saving in file for wrong file directory

I have two UITextField email password These two field values are stored in a NSMutableDictionary call userData. Now i want to save these two field values in a file, so that the records keep there and i can restore this record to check user login…
Tulon
  • 4,011
  • 6
  • 36
  • 56
-1
votes
1 answer

How to add the value of string into hashtable in iPhone coding?

for(NSString *s in mainarr) { NSString newseparator = @"="; NSArray *subarray = [s componentsSeparatedByString : newseparator]; //Copying the elements of array into key and object string variables NSString *key = [subarray…
suse
  • 10,503
  • 23
  • 79
  • 113
-1
votes
1 answer

Get whole object from NSMutableDictionary for current cellForRowAtIndexPath and assign it to a CustomCell

I have the following type of a NSMutableDictionary ( { id = 1; key = value; key = value; }, { id = 2; key = value; key = value; } ) It contains multiple data of an own Object.…
Musterknabe
  • 5,763
  • 14
  • 61
  • 117
-1
votes
1 answer

Replace values inside NSMutableDicitionary that sits inside a NSMutableArray

I have an NSMutableArray that I have build up that consists or holds a NSMutableDictionary. NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; self.userNameArray = [NSMutableArray arrayWithArray:[userDefaults…
-1
votes
2 answers

How to get a value from dictionary in iOS?

I want to get value from NSMutableDictionary. here is my dictionary : { "Balloon" = { "fields_id" = 1; "fields_list" = "Balloon"; "posm_details" = ""; }; "Booklet" = { …
Anand Gautam
  • 2,541
  • 3
  • 34
  • 70
-1
votes
4 answers

value with apostrophe are not inserted correctly in NSmutableDictionary

I want to create a dictionary with key "name" and number with value "George’s iPhone" and "123456". My code is: NSString *name = @"George’s iPhone"; NSMutableDictionary *dict = [[NSMutableDictionary alloc]init]; [dict setValue:@"123456"…
Mary
  • 335
  • 4
  • 14
-1
votes
1 answer

When a row is selected in the table, do something on the other table?

I have three tables in a view, I need to implement this kind of structure; I need to control if the row is selected in the first table, then adding rows of the third table to other view. when i press the button, the data of the selected and the…
erdemgc
  • 1,701
  • 3
  • 23
  • 43
-1
votes
1 answer

Blocks, Thread-safety, and NSMutableDictionary

I am adding objects to the same NSMutableDictionary from several different blocks in Objective-C. These blocks are all callback functions for some other process; that is, they will be called at some undetermined point in the future when the…
-1
votes
3 answers

Dispatch Queue and global NSMutableDictionary - Objective C

I'm trying to use a global NSMutableDictionary from a dispatch queue. However, the items keep coming back NULL. What I'm trying to do is access an external json file with a dispatch_queue, then populate a UITableView with this info. Here's what I…
Troy
  • 961
  • 6
  • 13
  • 24
-1
votes
1 answer

adding NSMutableDictionary to NSMutableDictionary adds dictionaries as string

I'm adding items from one nsmutabledictionary to another nsmutabledictionary but the dictionaries are been add it as string values and not as dictionaries. Here is my code: // mainDictionary contains dictionaries NSMutableDictionary…
HelenaM
  • 1,807
  • 6
  • 30
  • 41
-1
votes
1 answer

How to add an NSMutableArray into NSMutableDictionary as a key?

I have an array storing some attributes (those attributes are: tableID(string), tables coordinate(x,y coordinate in float)). Does anyone know how to store this array into NSMutableDictionary? And I need this NSMutableDictionary transfer into JSON…
ISAAC
  • 3
  • 3
-1
votes
2 answers

Want to store NSRange and NSInteger inside NSMutableDictionry

I need to store both the NSRange object and NSInteger inside the NSMutableDictionary? Can I do it? If it is, Could you give me an example?
Kirubachari
  • 688
  • 11
  • 27