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

I want to store NSString data in NSMutableDictionary

I'm trying to store data in NSMutableDictionary. continue change NSString value I want to store this value in NSMutableDictionary, but when second time store value in NSMutableDictionary then clear old value so how to store one by one value in…
-3
votes
1 answer

How to find mutated object while being enumerated in ios

Hi one of my application is crashsing with below error is there any way to find at which object it's actually crashing using instruments. Crash Message: Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection…
user3341324
  • 45
  • 1
  • 9
-3
votes
1 answer

Adding up objects within a key within an nsmutablearray

I have a nsmutablearray called temparray. That nsmutablearray has a key called "mountains". The objects inside the key mountains are 14, 12, 16, 20, 20, 20. How do I add up the objects inside the key "mountains" only for objects equal to a string…
-3
votes
1 answer

ios how to remove duplicates in a nsmutablearray of dictionaries

I need to merge two nsmutablearrays of dictionaries but my question is there is a way to either remove the duplicate dictionaries ? I'll really appreciate your help.
HelenaM
  • 1,807
  • 6
  • 30
  • 41
-3
votes
1 answer

Multiple objects into plist

I'm trying to add multiple objects to a plist, from the same UITextField. I explain better. I have an UITextField from which I add a phone number to a plist. The problem is that I can't add more than one number to that plist from only one…
-4
votes
2 answers

After adding element in NSMutableArray previous elements gets replaced

I'm working on app in which I want to create array with number of NSDictionary's. When i'm trying to add NSMutableDictionary in NSMutableArray, previously added elements of that array get replaced. I don't know what is happening. Code as…
sagar ss
  • 23
  • 7
-4
votes
3 answers

Condition checking on NSMutableDictionary

I have NSMutableDictionary with (key,value) pairs.For JournalId the key is "journalId".I just want to check whether my dictionary contains specific "journalId", for eg, 29. If it exists, need to print the corresponding title and userId. eg. { …
thipoo24
  • 138
  • 15
-4
votes
2 answers

Create array of dictionaries in objective c

I am fetching dictionaries from my local database. My database array with name aryTitle_DB structure is as mentioned below. ( { "date":13/9/2014; "title"="abc" }, { "date":13/9/2014; "title"="def" }, { "date":13/9/2014; …
-4
votes
1 answer

Select Group and Keys in NSDictionary

I have an NSMutableArray inside a variable called myMutableDictionary in this format: 2 = ( 4, 6 ); 3 = ( 7, 8 ) How I can select the number 4 inside the group 2?
-4
votes
1 answer

how do I sort my NSMutableDictionary by the keys?

I have a Dictionary AlphaSite BetaSite GammaSite I saw how can I sort NSMutableDictionary with keys value? but didnt help me much dictionaryOfWebsites = [[NSMutableDictionary alloc] init]; [dictionaryOfWebsites setObject:@"http://www.site1.com"…
Cocoa Dev
  • 9,361
  • 31
  • 109
  • 177
-4
votes
3 answers

How to reinitialize NSMutableDictionary in an ARC project?

I have a class level NSMutableDictionary object that I need to initialize, and reinitialize. Since my project is ARC, I am not sure if I can use release. What is correct way to do it? My current code results into a crash: myDict =…
-5
votes
2 answers

get contents of NSMutableDictionary into NSMutable array

How to get contents of NSMutableDictionary into NSMutable array? I am trying following but its crashing for(int i=0; i< [dict count] ; i++){ [array_listToDisplay addObject:[dict objectAtIndex:i] objectForKey:@"NAMES"]; } Please help
iOSDev
  • 3,617
  • 10
  • 51
  • 91
-5
votes
1 answer

sort dictionary with custom key in swift 2

I have a dictionary with keys in format: [1:ABC, 113:NUX, 78:BUN, 34:POI, 223:NTY] When I sorted the array of keys, i get the sorted key array as: [1:ABC, 113:NUX, 223:NTY, 34:POI, 78:BUN] But I want the sorted array as: [1:ABC, 34:POI, 78:BUN,…
-5
votes
5 answers

NSMutableDictionary in xcode to store entries

I'm creating an iOS application where the user inputs a Student ID, Student Forename and Student Surname... it then stores and shows this in a table view (The data will later be uploaded to an external database) how do I go about this? Is…
-5
votes
1 answer

How to pass the dictionary data to TableView at cellForRowAtIndexPath with dynamic Keys and Values in iOS?

if ([[[testMenuGroupAry objectAtIndex:0]objectAtIndex:group] isEqualToString:[filteredAry objectAtIndex:objCount]]) { NSLog(@"object count is %d",objCount); [groupAry addObject:[itemList objectAtIndex:group]]; } } …
Jyoshna
  • 253
  • 3
  • 14
1 2 3
87
88