nsdictionary

Very large NSDictionary vs Core Data vs SQLite for read-only look up on iPhone?

I'm tinkering around with a iPhone word app where I am using a DAWG structure for finding anagrams from a user defined word bank in real time as the user types. That part works well. As the words are identified, I want to retrieve specific information about each word which I currently have in a plist file (keyed by word). This informa...

Display NSArray values that are stored in an NSDictionary

I'm trying to store an NSArray object with a simple key (1,2,3 etc.) inside an NSDictionary. I'm pretty sure thats worked, but I'm not sure how to display the array data thats stored in there, I've got the following working (displaying a single array of data) The test app i'm working on is a simple dictionary. Definition is the class i'...

Cocoa - NSDictionary objectForKey - memory management clarification

[I have read the Cocoa memory management rules, but still want to be certain, and would like to know if this is good form.] My class has a mutable dictionary ivar: NSMutableDictionary *m_Dict; ... m_Dict = [NSMutableDictionary dictionaryWithCapacity:10]; [m_Dict retain]; At some point I'll add a mutable array to the dictionary: NS...

Saving a dictionary to the iPhone is not working?

Been a tough week, will try to make this as clear as possible. Appreciate you taking the time to read. Hi, I'm sending a registration request to a server. A user object in jSon is returned, I parse the jSon and save the jSon dictionary phone as a method on my User class. However, whenever I load the user from the phone - by reading the ...

Is there a reverse "setValuesForKeysWithDictionary" - a makeDictionaryWithObjectProperties?

Hi I parse some JSON from a web service, this gives me an NSDictionary, I use this dictionary to populated properties on a valueEntity of type NSObject by [myObject setValuesForKeysWithDictionary:JSONDict]; (myObject has the same property names and types as the dictionary from the JSON parser) name = name count = count startDate = ...

Wired NSDictionary problem...

Hello, i have the following code : NSDictionary *dict =[[NSDictionary alloc]initWithObjectsAndKeys:myarray1,@"array1",myarray2,@"array2",nil]; NSArray *shorts=[[dict allKeys]sortedArrayUsingSelector:@selector(compare:)]; for(NSString *dir in shorts){ NSArray *tempArr=[dict objectForKey:dir]; for(NSString ...

Challenging pList Iterating and NSDictionary problem

I have a pList file: Root - Dictionary categories - Array item 0 - Dictionary item 1 - Dict item 2 - Dict I load the file like so: -(void) loadCategories { // Loads the categories from the SymbolList.plist file NSString *file = [[NSBundle mainBundle] pathForResource:@"SymbolList" ofType:@"plist"]; NSMutab...

iPhone NSDictionary objectForKey: vs valueForKey: performance

In a code base I work with method valueForKey: is often used instead of objectForKey:. I have to optimize few methods that does this and was thinking if changing this to objectForKey: will introduce some performance gains? ...

NSDictionary into a NSInputStream

Hi there Is it possible to put in my NSDictionary into a NSInputStream? This would be my NSDictionary NSArray *keys = [NSArray arrayWithObjects:@"name", @"device_token", @"identifier", nil]; NSArray *values = [NSArray arrayWithObjects:@"Test iPhone", initDeviceToken, [UIDevice currentDevice].uniqueIdentifier, nil]; NSDictionary *parame...

Unique keys in NSDictionary - how to check given keys are copies?

I have an NSDictionary in which I use my own classes (NSObject subclasses) as keys and would like to make sure that I do not include the same key twice. However, because NSDictionary copies its keys, if I try to check whether an object is in the dictionary, it never thinks it is. For example, MyClass* obj = [[MyClass alloc] init]; NSMut...

Problem in copying data of one NSDictionary to another

Hello i am having problem in copying data from one NSDictionary to another i used the [dicForFoodproduct_fromWeb initWithDictionary:dictforfoodproduct]; Here it terminates and says "unrecognized selecter sent to the instance..." I am getting 5 key values in dictForFoodProduct but am unable to copy that key values into dicForFoodProduc...

NSDictionary sort by keys as floats

Hi there basically I have an NSDictionary with keys and values. The keys are all numbers, but at the moment they are strings. I want to be able to compare them as numbers in order to sort them. eg: If I have a Dictionary like this: { "100" => (id)object, "20" => (id)object, "10" => (id)object, "1000" => (id)object, } ...

NSDictionary split into two arrays (objects and keys) and then sorted both by the objects array (or a similar solution)

Hi there I have an NSDictionary. It has keys and objects. For the purposes of simplicity the keys are Question numbers and the objects are calculated Answer scores. Now how I did it before was that I set the answer score as the keys and the question numbers as the objects. This way I could get an array of allKeys from the dictionary, ...

Read/Write to a plist file that comes bundled with the app

Hi I am building an add-on to my app where the user can search for an item in a list that is pre-populated with data from a .plist file. It is an NSDictionary. If the term, the user searched for, does not exist, the user can tap a + button and add it so it is there the next time. First of I thought it would be as easy as using the NSUs...

Restoring a BOOL inside an NSDictionary from a plist file

I have a plist file which contains an array of dictionaries. Here is one of them: Fred Dictionary Name Fred isMale [box is checked] So now I am initializing my Person object with the dictionary I read from the plist file: -(id) initWithDictionary: (NSDictionary *) dictionary { if (self = [super init]) self.name =...

is it possible to save NSMutableArray or NSDictionary data as file in iOS ?

i want to save NSMutableArray or NSDictionary to save as file and close application. then reopen application and read some data from that file to use. is it possible? ...

Sorting NSDictionary with multiple constraints

I have a NSDictionary collection whose key is a unique id and value is an array with two different objects (FruitClass, ProductClass) and I would like to group the collection such that it's sorted first by ProductClass.productName and then by FruitClass.itemName. So the final list would look something like: {apple, butter} {apple, pie...

Storing different data types in a NSArray

I'm trying to store different data types in a NSDictionary to save in NSUserdefaults when the game terminates. I'm trying to store a char, 3 floats and a string, I keep getting a warning on the char and the floats and I cant seem to find the answer anywhere. 1)Do i even need to setup the arrays? 2) How do I store the different data types...

Open specific trail with a url scheme from NSDictionary.

Hi, I am using TouchJSON to retrieve the JSON response from http://enbr.co.cc/TrailsApp/shops.php. In my app I use this code to handle a url scheme. - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { if (!url) { return NO; } NSString *urlString = [url absoluteString]; NSString *urlStrin...

Creating a constant dictionary object

I would like to accomplish something like what is being done in this post: http://stackoverflow.com/q/538996/252428 however, i would like to construct an NSDictionary. if i do something like: constants.h extern NSArray *const mFooKeys; extern NSArray *const mFooObjects; extern NSDictionary *const mFooDictionary; constants.m NSAr...