当我尝试这段代码时:
if ([[NSFileManager defaultManager] fileExistsAtPath:@"~/Library/Application Support/Staying Afloat/stats/static-stats.plist"] == NO) {
NSMutableDictionary* tempDict = [[NSMutableDictionary alloc]initWithObjectsAndKeys:
[[NSString alloc] initWithString:@"0"],@"completedGames",
[[NSString alloc] initWithString:@"0"],@"floatsCollected",
[[NSString alloc] initWithString:@"0"],@"sec",
[[NSString alloc] initWithString:@"0"],@"subScore",
[[NSString alloc] initWithString:@"0"],@"highScore",
[[NSString alloc] initWithString:@"0"],@"longestSec", nil];
[tempDict writeToFile:@"~/Library/Application Support/Staying Afloat/stats/static-stats.plist" atomically:YES];
NSLog(@"written file");
}
这与输出
2012-04-14 19:15:10.009 Staying Afloat[3227:9c07] written file
所以循环已经运行,但文件没有被写入?谁能指出我将 plist 保存到非本地化位置的正确方向?
编辑:这是为 mac