我有一个NSMutableArray
,我想更改特定对象的值。
然而,它并没有改变。
以下是我的代码:
//create two array to store data later
NSMutableArray *feelingsArray = [[NSMutableArray alloc] init];
// get paths from root direcory
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *feelingsPath = [documentsPath stringByAppendingPathComponent:@"Feeling.plist"];
//This copies objects of plist to array if there is one
[feelingsArray addObjectsFromArray:[NSArray arrayWithContentsOfFile:feelingsPath]];
//replace object at particular location
[datesArray replaceObjectAtIndex:number withObject:feeling.text];
我是否需要进行任何更改或添加一些代码,例如同步等。
请提供一些指导。
答案 0 :(得分:2)
应该不是
[datesArray replaceObjectAtIndex:number withObject:feeling.text];
是
[feelingsArray replaceObjectAtIndex:number withObject:feeling.text];