Can not read and save a number from/into an .plist
- by Flocked
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?