【发布时间】:2012-01-25 20:26:36
【问题描述】:
我有一个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];
我是否需要进行任何更改或添加一些代码,例如同步等?
请提供一些指导。
【问题讨论】:
-
感觉数组和替换有什么关系?为什么包含该代码?替换只使用 datesArray、number 和感觉。
标签: objective-c ios nsmutablearray nsarray