cnu
cnu

Reputation: 815

NSMutableArray. Object value is not being replaced

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.

Upvotes: 0

Views: 191

Answers (1)

Emile Cormier
Emile Cormier

Reputation: 29219

Shouldn't

[datesArray replaceObjectAtIndex:number withObject:feeling.text];

be

[feelingsArray replaceObjectAtIndex:number withObject:feeling.text];

?

Upvotes: 2

Related Questions