NSMutableArray。对象值没有被替换
我有一个 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];
我需要进行任何更改或添加一些代码(例如同步等)吗?
请提供一些指导。
I have a NSMutableArray
and I want to change the value of a particular object.
However, it's not changing.
Below is my code:
//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];
Do I need to make any changes or add some code like synchronise etc.?
Please provide some guidance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不应该
吗
?
Shouldn't
be
?