nsdictionary

iPhone SDK: How do I properly save user-inputted information into a .plist or other file?

I've looked through the SDK documentation and through other questions that have been asked, and I am still a little confused on how exactly to do this. I had been previously been working with the following code, though it does not give the desired result of a .plist file. Besides mentioning the IBAction in the header files in this code...

Sending NSDictionary between phones

I have an application where a user creates settings that are stored in an NSMutableDictionary. I have to send this to a server, where it can be later retrieved by a recipient. I can serialize the dictionary, and send it to the server. My question is, if I send it as NSData, store it in a blob field in my postgresql db, and then send it...

iPhone - accessing a NSDictionary

Hello! I have a JSON String which I transform to a NSDictionary, and the I get the values for the key "people" to a NSDictionary: NSDictionary *testDict = [jsonString JSONValue]; NSDictionary *peopleDict = [testDict objectForKey:@"people"]; A NSLog of peopleDict NSLog(@"%@", peopleDict); return me the following: { 0 = { i...

Memory management with dictionaries / possible misinterpretation by GCC?

Hi, Somewhere on my code I need to create several windows from a main window, each functioning with a specific configuration but all instances of the same controller object. I also need to keep a list of open windows, so whenever I open a window I store its instance in a dictionary and when the window is closed I send a notification to...

How to insert an object at a given index in iphone-sdk

I want to insert a object at a given index. and If Is there no object at the index, I want to know that. Is NSDictionary good choice? Is there another good solution? // Initailization NSMutableDictionary *items = [NSMutaleDictionary dictionary]; ... // insert an object. [items setObject:item forKey:[NSNumber numberWithInt:3]]; ... // ...

Objective c, Memory Leak, reading from sqlite and assigning values to a NSDictionary and NSAarray

I have a list of shops in a ListController file. I've setted up a sqlite db, in which i've stored 60 shops. On the top of the list i have a search bar. I've made a class called DataController, that is responsible to load and store db datas. @interface DataController : NSObject { sqlite3 *database; NSArray *shops; NSDictionary* ...

string value stored in NSDictionary

I am trying to implement this button action, but the if statement is not evaluating to be true. I have a situation where the value in that "School" dictionary will not always have a website stored. For that reason i want to check, but what do i check against. If "nil" is not stored there when there is not a value, then what is? -(IBAct...

fast enumeration on NSDictionary fails with "[Waypoint countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance ..."

Hello, I have my data in a NSDictionary object where the keys are CGPoints converted to NSValues and the objects are UIColors. Here's the method I'm using to return an object from the dictionary: - (UIColor*) getTemperatureColor2 { NSDictionary* temperatureColorMap = [Weather getTemperatureColorMap]; for(id key in temperatu...

iPhone Objects from NSDictionary PList

Hello, in my app I have a section where I load from a saved plist which has 2 nested dictionaries like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; <plist version="1.0"> <dict> <key>1</key> <dict> <key>color</key> ...

iPhone performSelector changes object type

I have a callback class with the method -(void)fire and it calls [target performSelector:selector withObject:dictionary]; Just before that line I added NSLog(@"%@", [[dictionary class] description]); to see where the object changed, when debugging it returns NSCFDictionary. So that was all fine. Next I went and added a similar line to g...

iphone: How do you find the creation date of a file?

hi all. I'm trying to find the creation date (NOT modification date) of a file. Creation date doesn't appear to be in the attributes of a file, though modified date is. I'm using this code.. NSFileManager* fm = [NSFileManager defaultManager]; NSString* path = [PathHelpers pathInDocumentsFolderWithFilename:FILE_NAME]; NSDictionary* a...

Can I put an ObjectiveC @selector in a NSDictionary?

[actionMap setObject:@selector(actionNavPop) forKey:@"navPop"]; This doesn't work. NSDictionary can only hold objects, and a SEL type is not an object. For number types you can do [NSNumber numberWithInt:123] but is there any sort of similar object wrapper for selectors? ...

Plist not saving from dictionary (to Documents)

I've been trying to save a plist of a NSDictionary to my app's Documents folder. I haven't tried this on the device yet but I'd like it to work on the simulator for testing purposes. The [self createDictionaryFromChoreList] method just creates a NSDictionary from some data in another class of mine. I've pretty much copied/pasted this cod...

How do I convert NSDictionary to NSData as a plist (without saving the dictionary)

Does anyone know how to convert a NSDictionary object into an NSData object as a plist without saving the dictionary first? I would like my iphone app to send an email with a plist containing my dictionary attached. I am currently using skpsmtpmessage, http://code.google.com/p/skpsmtpmessage/, to send email. Thanks in advance ...

Objective C - convert array of objects (with date field) into dictionary of arrays (keyed by day of week)

Hello, I have an NSArray of DiaryEntry objects, where each DiaryEntry has an NSDate date_ field. I want to display all of the DiaryEntrys in a table view, grouped by the day of the week, where each group is sorted by date in ascending order. So, I need to take the NSArray, and convert to an NSDictionary of arrays, where the key is the...

for each loop in objective c for accessing NSMutable dictionary

I am finding some difficulty in accessing mutable dictionary keys and values in Objective-C. Suppose I have this: NSMutableDictionary *xyz=[[NSMutableDictionary alloc] init]; I can set keys and values. Now, I just want to access each key and value, but I don't know the number of keys set. In PHP it is very easy, something as follows...

a problem when get Number type in Dictionary (iPhone)

here is my plist and code > <plist version="1.0"> > <dict> > <key>Title</key> > <string>News</string> > <key>icon</key> > <integer>0</integer> > </dict> > </plist> int i = [dictionary objectForKey:@"icon"]; NSLog(@"%d",i); log result is 81841904 why it not 0 ? ...

iPhone Obj C -- Sorting a Mutable Array of dictionaries -- display a string but sort by value

I have a NSMutableArray with 30 dictionaries inside of it. Each contains a name and a value. I currently have the names sorted so that the show in a table view alphabetically. However, I'd like to make a UIButton to give the option of STILL DISPLAYING THE NAMES, but ordered by the value. The value doesn't need to be displayed. Also, whe...

NSDictionary: URL-Encoding

Can anyone please review the following method and tell me if it is necessary to release the enumerator for the dictionary keys after using it? I'm new to objective c and not always sure, when to release variables returned from the SDK methods. I suppose the keyEnumerator method returns an autoreleased instance so I don't have to care abo...

A NSDictionary that doesn't copy keys for iPhone 3.0 SDK?

Hello, I am using NSDictionary as an associated array (i.e, the keys i am using can be any arbitrary objects). One of the very annoying thing about NSDictionary is that it always make a copy of the key and store it. In my scenario, I will later retrieve the keys from the NSDictionary and do some operations with them. The operation happe...