1
此代码适用于模拟器,但不适用于设备。我肯定这有什么写作做文件:writeToFile在SIM卡中工作,但不在设备上
NSString *path = [[NSBundle mainBundle] pathForResource:@"SongData" ofType:@"plist"];
NSArray *tempData = [[NSArray alloc] initWithContentsOfFile: path];
NSMutableArray *arr = [[NSMutableArray alloc] init];
for (NSDictionary *dict in tempData) {
NSMutableDictionary *new = [[dict mutableCopy] autorelease];
if ([[new objectForKey:@"Song Title"] isEqualToString:[[tableData objectAtIndex:[indexPath row]] objectForKey:@"Song Title"]]) {
BOOL fav = [[new objectForKey:@"Favorite"] boolValue];
[new setObject:[NSNumber numberWithBool:!fav] forKey:@"Favorite"];
}
[arr addObject:new];
}
[arr writeToFile:path atomically:YES];
我基本上写入文件的NSMutableArray里,我不知道是什么意思原子,但我试图既肯定又否定,既不要工作。
谢谢。
我想通了,但感谢。 – user635064 2011-05-15 00:34:21