-1
添加NSMutableDictionnary到NSMutableArray裏有人能告訴我什麼是錯的一段代碼:中的.plist
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];
的scores.plist被添加到我的項目(支持文件)和看起來像這樣
<?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>
謝謝
謝謝,我不知道我不能在應用程序的編寫捆綁。現在它工作正常。 – 2012-02-22 15:44:15