Can not read and save a number from/into an .plist

Posted by Flocked on Stack Overflow See other posts from Stack Overflow or by Flocked
Published on 2010-03-21T20:33:19Z Indexed on 2010/03/21 20:41 UTC
Read the original article Hit count: 409

Hello, I created a property list with the name propertys.plist. Then I wrote this:

NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"speicherung.plist"];
NSMutableArray *plistData = [[NSMutableArray arrayWithContentsOfFile:finalPath] retain];
int a = [plistData objectAtIndex:1];
NSLog(@"%i", a); // returns 41386032, but the right number is 0
a = a + 1;
NSNumber *ff = [NSNumber numberWithInt:a];
[plistData insertObject:ff atIndex:1];
NSLog(@"%@", [plistData objectAtIndex:1]); // returns 41386033
[plistData writeToFile:finalPath atomically:YES];

My app always get the wrong number. Why?

© Stack Overflow or respective owner

Related posts about property-list

Related posts about nsnumber