辞書を含むplistがdict
あり、dictにはキーA、B、Cの3つの配列があります。今、特定の状況下で A、B、C に項目を追加したいと考えています。このために、私はこのようにしています...
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *documentsDirectory = [path objectAtIndex:0];
NSString *plistPath = [documentsDirectory stringByAppendingString:@"MovingChecklist.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
if (![fileManager fileExistsAtPath: plistPath])
{
NSString *bundle = [[NSBundle mainBundle] pathForResource:@"MovingChecklist" ofType:@"plist"];
[fileManager copyItemAtPath:bundle toPath: plistPath error:&error];
}
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
NSArray *array1 = [dict objectForKey:@"A"];
NSArray *array2 = [dict objectForKey:@"B"];
NSArray *array3 = [dict objectForKey:@"C"];
NSMutableArray *myArray;
if (currentMovingList == KMovingListTypeA) {
myArray = [NSMutableArray arrayWithArray:array1];
[myArray addObject:nameTextView.text];
[dict setValue:myArray forKey:@"A"];
}
if (currentMovingList == KMovingListTypeB) {
myArray = [NSMutableArray arrayWithArray:array2];
[myArray addObject:nameTextView.text];
[dict setValue:myArray forKey:@"B"];
}
if (currentMovingList == KMovingListTypeC) {
myArray = [NSMutableArray arrayWithArray:array3];
[myArray addObject:nameTextView.text];
[dict setValue:myArray forKey:@"C"];
}
[dict writeToFile:plistPath atomically: YES];
しかし、plistは変更されていません。私がしている間違いを教えてください。