Can somebody tell me what's wrong with that piece of code :
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"scores" ofType:@"plist"];
NSMutableArray *data = [[NSMutableArray alloc] initWithContentsOfFile:plistPath];
NSMutableDictionary *userDict = [[NSMutableDictionary alloc] init];
[userDict setValue:firstname forKey:@"firstname"];
[userDict setValue:[NSNumber numberWithInt:0 ] forKey:@"successes"];
[userDict setValue:[NSNumber numberWithInt:0 ] forKey:@"fails"];
[data insertObject:userDict atIndex:0];
[data writeToFile:plistPath atomically:YES];
[userDict release];
[data release];
The scores.plist is added to my project (Supporting Files) and look 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">
<plist version="1.0">
<array>
</array>
</plist>
Thanks