nsmutabledictionary

iPhone: Not able to store NSMutableDictionary to NSUserDefaults

孤街醉人 提交于 2019-12-21 05:56:40
问题 I am trying to implemen "Add to Favorites" functionality using NSMutableDictionary as I have to add multiple key-values. The following addToFavourites method always display Count=0 even after adding object to dictionary. I read this and getting nsdefaults into mutabledictionary(instead of mutable array) and setting resulted dictionary back to nsdefaults but not sure what's the problem. Any help would be really appreciated. Thank you. Edited: From this I came to know that I have to move data

What's the best way to store and retrieve multi-dimensional NSMutableArrays?

孤者浪人 提交于 2019-12-21 02:29:09
问题 I'm storing a bunch of data in a .plist file (in the application documents folder), and it's structured like this: Dictionary { "description" = "String Value", "sections" = Array ( Array ( Number, ... Number ), Array ( Number, ... Number ) ), "items" = Array ( Array ( Number, ... Number ), Array ( Number, ... Number ) ) } If I just retrieve it with NSMutableDictionary *d = [[NSMutableDictionary alloc] initWithContentsOfFile:plistFile] I won't be able to replace the number objects, correct? So

Why would my NSMutableDictionary be nil?

独自空忆成欢 提交于 2019-12-20 07:57:07
问题 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 *dTemp = [[NSMutableDictionary alloc] init]; STStockData *stockData = [[STStockData alloc] init]; for (int i = 0; i < [_arrTickers count]; i++) { // get the ticker from its json form dTemp = [_arrTickers objectAtIndex:i]; NSLog(@"Ticker: %@",[dTemp

How to get NSMutableDictionary count in iphone?

回眸只為那壹抹淺笑 提交于 2019-12-19 12:49:22
问题 I want to get NSMutableDictionary count in iphone. I want to know how many items are in NSMutableDictionry. I tried these code to find out the solution but, not helped me lot. NSLog(@"Count : %d", [mutableDictionary count]); It is always returns '0'. How to get the count of NSMutableDictionary in iPhone? Thanks in advance. 回答1: You can find out how many key-object (key-value) pairs there are like so: NSArray * allKeys = [mutableDictionary allKeys]; NSLog(@"Count : %d", [allKeys count]); EDIT

separating keys and objects from NSMutable dictionary and use the values in insert command of sqlite

僤鯓⒐⒋嵵緔 提交于 2019-12-19 10:56:23
问题 hi folks i am developing an sqlite application in iphone. since i am new to this application, i dont how to use the key and objects from NSMutableDictionary in the command of insert statement of sqlite. for example , i want the insert statement in the following format. INSERT INTO TABLENAME (COLUMN NAMES AS KEYS FROM NSMUTABLEDICTIONRY) VALUES (VALUES AS OBJECTS FROM NSMUTABLEDICTIONARY) please help me out. thanks 回答1: I have actually very little knowledge about SQL, but maybe something like

How to get the key for a given object from an NSMutableDictionary?

丶灬走出姿态 提交于 2019-12-18 12:05:56
问题 I have an object which is in an big NSMutableDictionary, and need to find out which key this has. So I want to look up that "table" from both columns. Not only with keys, but also with objects (to get keys). Is that possible? 回答1: Look to the parent class (NSDictionary) - (NSArray *)allKeysForObject:(id)anObject Which will return a NSArray of all the keys for a given Object Value. BUT it does this by sending an isEqual message to each object of the Dictionary so for your large dataset this

Issue : Convert an Object to json in iOS

▼魔方 西西 提交于 2019-12-18 09:56:15
问题 I have one main entity class with name "Store" like : Store.h :- #import <Foundation/Foundation.h> #import "SignIn.h" @interface Store : NSObject @property (nonatomic, retain) NSString *storeId; @property (nonatomic, retain) NSString *storeProfileId; @property (nonatomic, retain) NSString *storeName; @property (nonatomic, retain) NSString *storeRegion; @property (nonatomic, retain) SignIn *signIn; @end Store.m :- #import "Store.h" @implementation Store @synthesize storeId, storeProfileId,

Unrecognized selector when adding an object to NSMutableArray

别说谁变了你拦得住时间么 提交于 2019-12-18 09:24:21
问题 I have a singleton class with a NSMutableArray property to which I want to add objects and remove objects. For some reason I am getting: -[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance 0x1edf24c0 exception when trying to add to it. Here is the relevant code for the interface of the singleton: //outbox item is the type of objects to be held in the dictionary @interface OutboxItem : NSObject @property (nonatomic, assign) unsigned long long size; @end @interface

How to insert a new key with value in dictionary

梦想的初衷 提交于 2019-12-18 05:27:13
问题 I want to insert a key with a corresponding value in an existing dictionary... I am able to set values for existing keys in the dictionary, but I am not able to add a new key value... Any help would be appreciated. 回答1: Use NSMutableDictionary NSMutableDictionary *yourMutableDictionary = [NSMutableDictionary alloc] init]; [yourMutableDictionary setObject:@"Value" forKey:@"your key"]; Update for Swift: The following is the exact swift replica for the code mentioned above var

iPhone - Writing NSMutableDictionary to file

若如初见. 提交于 2019-12-17 20:59:53
问题 I'm having trouble in writing mutable dictionary to a file. Here's the code that I'm writing. I'm reading the file like below: (first time when app is ran, it won't have any data) NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* documentsDirectory = [paths objectAtIndex:0]; self.favSaveFilePath = [[NSString alloc] initWithString:[documentsDirectory stringByAppendingPathComponent:@"Favorites.plist"]]; if([fm fileExistsAtPath