writing NSDictionary to plist

Posted by ADude on Stack Overflow See other posts from Stack Overflow or by ADude
Published on 2010-03-23T17:34:45Z Indexed on 2010/03/23 17:43 UTC
Read the original article Hit count: 689

Filed under:
|
|
|
|

Hi

I'm trying to write an NSDictionary to a plist but when I open the plist no data has been written to it. From the log my path looks correct and my code is pretty standard. Any ideas?

NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", @"key3", nil]; NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", @"value3", nil]; NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];

for (id key in dictionary) {
    NSLog(@"key: %@, value: %@", key, [dictionary objectForKey:key]);
}

NSString *path = [[NSBundle mainBundle] pathForResource:@"FormData" ofType:@"plist"];
NSLog(@"path:%@", path);

[dictionary writeToFile:path atomically:YES];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsdictionary