0

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 
1
  • according to me you need to use NSMutableDictionary rather then array, and then after check the value of key of status. Commented Oct 1, 2012 at 6:49

2 Answers 2

1

You need to add code is like that in your some function

[status replaceObjectAtIndex:0 withObject:"Approved"];
Sign up to request clarification or add additional context in comments.

Comments

0

Just Replace value with index number of an Array

[yourArray replaceObjectAtIndex:0 withObject:@"Approved"];

:)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.