1
我的plist中的數據如何將陣列替換爲iPhone中的plist?
ArrayKey
item0 100
item1 200
item2 300
我的功能是
- (IBAction)Save:(id)sender
{
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"myPlist" ofType:@"plist"];
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc]
initWithContentsOfFile:plistPath];
NSMutableArray * array = (NSMutableArray *)[dictionary valueForKey:@"ArrayKey"];
[array replaceObjectAtIndex:0 withObject:textView1.text];
[array replaceObjectAtIndex:1 withObject:textView2.text];
[array replaceObjectAtIndex:2 withObject:textView3.text];
NSLog(@"Array is :%@",dictionary);
[dictionary writeToFile:plistPath atomically:YES];
}
哪裏是錯誤的。請幫助!
謝謝。