FAQ Database Discussion Community


Swift Dictionary [String:String] to NSMutableDictionary?

swift,dictionary,sprite-kit,nsmutabledictionary
I am trying to create and assign a Swift Dictionary of type [String : String] at the SKSpriteNode property userData which requires an NSMutableDictionary. When I try this I get the error: '[String : String]' is not convertible to 'NSMutableDictionary' Can anyone point me in the right direction? // USER...

NSMutableArray addObject using value and key

objective-c,iphone,nsmutablearray,nsmutabledictionary
I found some codes like this: for (int i = 0 ; i < pinyin_array.count; i++) { [pinyins_arr addObject:@{k_PINYIN : pinyin_array[i]}]; } where pinyins_arr is a NSMutableArray and Kk_PINYIN is a NSString. I am not sure if this is correct or not. I think it should be a NSMutableDictionary to...

When to and when not to use (mutable) copies in assignments (Objective C)

objective-c,nsmutabledictionary
I am new to Objective C and I had no idea that in an NS(Mutable)Dictionary I must use (mutable)Copy for an assignment like this: dict[@"backup"] = dict[@"myList"]; Using debugging I found out that the assignment must be done like this: dict[@"backup"] = [dict[@"myList"] mutableCopy]; Now the question is: how do...

NSDictionary in NSMutableArray ios

ios,objective-c,nsmutablearray,nsdictionary,nsmutabledictionary
I've a NSMutableArray array having NSDictionary keys as: NSMutableArray *[email protected][@{@"A":@{@"user":@"obj1",@"friend":@"obj2"}}]; No I want to add objects to this NSMutableArray. My Code: for (int i = 0; i < 10; i++) { NSString *user = @"A"+i; for(int i=0;i<50;i++) { NSString *friend1 = @"B"+i; NSString *friend2 = @"C"+i; NSString *friend3 = @"D"+i;...

Getting a particular key value for all object in JSON

ios,objective-c,json,nsmutablearray,nsmutabledictionary
This is my JSON: { "Frames": [ {"Image":"1.png", "Time":"0.04"}, {"Image":"2.png", "Time":"0.04"}, {"Image":"3.png", "Time":"0.04"}, {"Image":"4.png", "Time":"0.04"}, {"Image":"5.png", "Time":"0.04"}, {"Image":"6.png", "Time":"0.04"}, {"Image":"7.png", "Time":"0.04"}, {"Image":"8.png", "Time":"0.04"}, {"Image":"9.png", "Time":"0.04"}, {"Image":"10.png", "Time":"0.04"}, {"Image":"11.png", "Time":"0.04"}, {"Image":"12.png", "Time":"0.04"}, {"Image":"13.png", "Time":"0.04"}, {"Image":"14.png", "Time":"0.04"}, {"Image":"15.png",...

Order NSMutableDictionary for use with UITableView Where key is used in section header

uitableview,swift,nsmutabledictionary
I have a NSMutableDictionary that I use with a UITableView, in the table each section header is the value of a key and the cells for each section is derived from the key's value (an array). I would like the table view to have a specific key at the top...

NSDictionary and string literal keys

ios,objective-c,nsstring,nsdictionary,nsmutabledictionary
Does using a string literal like @"key" in setObject(id):forKey(id) only work because the compiler optimizes all instances of the string literal to point to the same object? Or does retrieving an object with objectForKey(id) actually compare the string value of the key? What if the NSDictionary was created by an...

How to check dictionary value is empty or not

swift,nsmutabledictionary
i am new to swift and facing little issue and i not understanding how to check dictionary value. func doValidate(data:Dictionary<String,AnyObject>,isEmail : String) -> Bool { if(isEmail=="signup"){ if( data["last_name"] == nil || data["email"] == nil || data["password"] == nil || data["first_name"] == nil){ return false; } else{ return true; } }...

Objective C Acessing NSMutableDictionay inside NSMutableDictionary

objective-c,object,nsmutabledictionary
I am a newcomer to objective C and I have serious problems in accessing NSMutableDictionarys. I have two objects (Network and Beacon), and I want to create a NSMutableDictionary of Networks with a NSMutableDictionary of Beacons inside. Network.h #import <Foundation/Foundation.h> @interface Network : NSObject{ NSString *id_network; NSString *major; NSString *active;...

Can't add object to NSMutableDictionary within Parse block

ios,objective-c,xcode,parse.com,nsmutabledictionary
I am downloading a sticker object from Parse.com and then downloading the image for it. For some reason it won't add to my dictionary. The object is created fine but it just won't add. code below: - (void)getNewStickersWithCompletionHandler:(stickerCompletionHandler)handler { __weak StickerManager *weakSelf = self; PFQuery *stickersQuery = [PFQuery queryWithClassName:@"sticker"]; NSNumber...

NSMutableDictionary keys pointing to nothing

ios,nsmutabledictionary
I have an NSMutableDictionary of NSArrays. Some of the keys I actually want to point to nothing. Right now I am using NSArray *someArray=[[NSArray alloc] init]; to represent nothing, i.e. an empty array. Is there a better way to do this?

Why is this NSString null in a FireBase query block?

ios,objective-c,firebase,objective-c-blocks,nsmutabledictionary
I can't figure out why this string is null inside the FQuery block. My app keeps crashing when I build the dailyLog MutableDictionary at the user key; NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"MMMM dd, YYYY"]; NSString *userID = [[self.userProfile objectForKey:@"userID"] copy]; self.logFirebase = [[Firebase alloc] initWithUrl:@"https://urlName.firebaseio.com/DailyLog"]; [[[self.logFirebase queryOrderedByPriority]...

Content of a NSMutableDictionnary erratically returned

cocoa,nsdictionary,nsmutabledictionary
I am trying to add keys in a dictionnary in Objective-C. The code is as follows : I have a class MyClass whose header file contains : @property (nonatomic) NSMutableDictionary *dict; This gets initialized as follows : _dict = [[NSMutableDictionary alloc] init]; Then I try to add keys to it...

Save multiple values with same keys in NSMutableDictionary then store the dictionary in NSMutableArray

ios,nsmutablearray,nsmutabledictionary
I know this question has been asked many times but not got the solution or i might not understood that's why posting the question. for (int web=0; web<[web_arr count]; web++) { AdditionalBookmark *web_book=[[AdditionalBookmark alloc]init]; UITextField *txtNam = (UITextField*)[self.view viewWithTag:1100+web]; NSString *txtName = txtNam.text; UITextField *txtLin = (UITextField*)[self.view viewWithTag:1200+web]; NSString *txtLink...

sorting nsmutablearray contaning dictionary in alphnumberic way

ios,sorting,nsmutablearray,nsmutabledictionary
I have array containing dictionary like below:- ( { "act_priority" = B1; } { "act_priority" = ""; } { "act_priority" = A; } { "act_priority" = A3; } { "act_priority" = B; } { "act_priority" = A2; } { "act_priority" = A1; } { "act_priority" = ""; } ) I...

Add to NSMutableDictionary without replacing similar keys

ios,objective-c,nsmutabledictionary
I am dynamically populating a NSMutableDictionary with keys that are identical. However doing so replaces the original keys value. What I require is it to be appended and not replacing the existing key. For example, I need a structure like { @"Key" : @"Value1", @"Key" : @"Value2", @"Key" : @"Value3"...

How to add objects in a NSMutableDictionary

ios,objective-c,nsmutabledictionary
I have an app that uses MKMapView. In my app, I have declared an array that will hold the response from the API. The data from the API are the jobs to be pinned in the map (clustered annotations). The array that holds the jobs from the API will/needs to...

Create NSDictionary from Dictionary Log printed by Xcode

ios,objective-c,nsdictionary,nsmutabledictionary
Is it possible to create Dictionary from string data that log area of xcode display. Like 0 = { "Key1" = "ABC"; }; 1 = { "Key1" = "DEF"; }; ...

How to remove value (not key) from NSmutableDictionary

ios,uitableview,nsmutabledictionary
I have a NSmutableDictionary which I use it to fill in the tableView. Now I want to make the rows in my tableView editable. Here is my code: - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } And when one select the row - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {...

Crash when I re-enter a TableViewController due to an attempt to write to what I think is a mutable dictionary

ios,objective-c,uitableview,nsuserdefaults,nsmutabledictionary
I have the following nested mutable dictionary which I create and save into NSUSerDefaults self.configDict is { objectsDict = { "40E1507D" = { lastUpdate = "2015-05-30 05:02:40 +0000"; subObjects = { "D84EA15E" = { lastUpdate = "2015-05-30 05:02:40 +0000"; show = 1; title = subObjectOne; }; "F20047D4" = { lastUpdate...

Looping through a nested NSMutableDictionary and filtering some items

ios,objective-c,loops,nested-loops,nsmutabledictionary
I have been stuck here for a while trying many things without any success. So i have a nested dictionary that looks like this: {"Div 3 Mellersta G\u00f6taland, herrar": { "0": {"awayScore": "0", "homeTeam": "Hestrafors IF", "tempTime": "12:00", "homeScore": "0", "awayTeam": "Gunnilse IS", "time": "90'", "events": []}, "1": {"awayScore": "0",...

Adding and getting values of NSMutableDictionary not working [duplicate]

objective-c,nsmutabledictionary
This question already has an answer here: NSMutableDictionary setObject:forKey: fails to add key 1 answer I'm trying to do some complex stuff, but when I add to an nsmutabledictionary and try to get values from it, it's simply returning nothing and not printing anything when I try to print...

change object get from NSUserDefaults

ios,objective-c,nsmutablearray,nsuserdefaults,nsmutabledictionary
I’d like to change object get from NSUserDefaults. But when executing following code, the app crash with error message: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object’ I have this code. NSUserDefaults* pref = [NSUserDefaults standardUserDefaults]; NSMutableArray* data = [[NSMutableArray alloc]init];...

How to search something in NSMutableDictionary

ios,objective-c,nsmutablearray,nsmutabledictionary
Hello I have a NSMutableArray like this Contactarray ( { "firstNAme"="name1" "lastName"="name2" "phoneNumber"="12345678902"; } { "firstNAme"="name1" "lastName"="name2" "phoneNumber"="12345678902"; } I want to search the person when I type the person name in my UITextField. Then the filtered UItableView should be loaded. This NSMutableArray contains NSMutableDictionaries. How can I find the...

NSMutableDictionary VS NSMutableArray speed

ios,objective-c,xcode,nsmutablearray,nsmutabledictionary
I am using a cache for images that are downloaded from Parse.com. Images are used as the background images for UIButtons in a UITableView's cells. The images are stored in an NSMutableDictionary. code below: PFUser *user =self.currentUser.friends[(int)indexPath.row*4+i]; label.text=user.username; UIImage *cachedImage = self.images[@(indexPath.row*4+i)]; if (cachedImage) { NSLog(@"Have image"); [button setBackgroundImage:cachedImage forState:UIControlStateNormal];...

iOS - Adding objects to NSMutableDictionary causing crash

ios,swift,nsmutablearray,nsmutabledictionary
In the app I'm developing I'm reading in a JSON file. This file contains a list of players. Each player has a series of attributes. I have created a Mutable Array and a Mutable Dictionary to store the data. I'm trying to store the dictionary into an array index. I'm...

-[__NSDictionaryM objectAtIndex:]: unrecognized selector sent to instance

ios,objective-c,xcode,nsmutabledictionary
I searched for all possible combinations and answers on SO, but didn't helped me a lot. All are related to UITableView only. What I am doing is I am fetching my Quiz from server. Quiz contain Sections and each section contain Questions. So flow is like this. Quiz->Section->Question I am...

saving facebook mutual friends to array or dictionary

objective-c,facebook-graph-api,nsmutablearray,nsmutabledictionary
This is probably a very novice question and I'm embarrassed to ask, but I've wasted a bunch of time trying to figure this out. I followed facebook's documentation and can now successfully retrieve mututal friends. The problem, I'm having trouble saving them to an array or dictionary. My goal is...

Get objectAtIndex from NSMutableDictionary

ios,objective-c,uitableview,uisearchbar,nsmutabledictionary
In my app, I'm working with UISearchBar where user will search from an NSMutableArray by searching with user name. Here is my method for searching user from NSMutableArray - (void)searchTableList { NSString *searchString = searchBar.text; NSMutableArray *searchArray = [[NSMutableArray alloc] init]; for (NSDictionary *dictionary in contentList) { NSArray *array =...

NSMutable dictionary, do I initialise every time it is used or save and load it to file?

ios,objective-c,nsmutabledictionary,nskeyedarchiver
I have a class that uses a NSMutableDictionary. This dictionary contains between 40-60 objects of a custom class "appStrings". Right now every time I used the class I just init the dictionary calling my initDictionary method and this adds all the objects and keys. Is it better/faster to instead init...

How to remove NSDictionary while iterating in NSMutableArray [duplicate]

ios,objective-c,nsdictionary,nsmutabledictionary
This question already has an answer here: Avoiding “NSArray was mutated while being enumerated” 8 answers I want to remove object from array when the name is same. How to do this? Thanks in advance. Here is my code NSString *name1; NSString *name2; NSArray *copyArray = [uniqueArraySort copy]; for...

Parse Nsmutabledictionary and extract value

ios,objective-c,json,nsdictionary,nsmutabledictionary
Hello everyone i have one problem in parsing a dictionary here is dictionary { "@id" = 10; activityLocation = ""; activityPriority = 1; actualEndDate = "<null>"; actualStartDate = "<null>"; children = ( ); } i am getting this responce in json and when i tried to parse this dictionay and...