Reputation: 7
I have declared an array in viewDidLoad.
-(void) viewDidLoad{
status=[[NSMutableArray alloc] init];
[status addObject:@"Pending"];
}
Now in some function I need to change the value of "Pending" to "Approved". and then check that condition in cellforRow. What I am currently doing is :
some function: [[ objectAtIndex:0] addObject: "Approved"];
cellForRow:
if( [[status objectAtIndex:0] isEqual:@"Pending"){
//do this
}
else if ([[status objectAtIndex:0] isEqual:@"Approved"){
//do that
}
It is throwing an exception:
NSInvalidArgumentException :[__ NSCFCConstantString addObject:]: unrecognized selector sent to instance
Upvotes: 0
Views: 50
Reputation: 20541
Just Replace value with index number of an Array
[yourArray replaceObjectAtIndex:0 withObject:@"Approved"];
:)
Upvotes: 0
Reputation: 1695
You need to add code is like that in your some function
[status replaceObjectAtIndex:0 withObject:"Approved"];
Upvotes: 1