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