0

我在 viewDidLoad 中声明了一个数组。

 -(void) viewDidLoad{
   status=[[NSMutableArray alloc] init];
   [status addObject:@"Pending"];
 }

现在在某些功能中,我需要将“待定”的值更改为“已批准”。然后在 cellforRow 中检查该条件。我目前正在做的是:

some function: [[ objectAtIndex:0] addObject: "Approved"];

cellForRow:  

if( [[status objectAtIndex:0] isEqual:@"Pending"){
  //do this
}
else if ([[status objectAtIndex:0] isEqual:@"Approved"){
  //do that
}

它抛出一个异常:

NSInvalidArgumentException :[__ NSCFCConstantString addObject:]: unrecognized selector sent to instance 
4

2 回答 2

1

您需要在某些功能中添加代码

[status replaceObjectAtIndex:0 withObject:"Approved"];
于 2012-10-01T06:50:54.817 回答
0

只需将值替换为数组的索引号

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

:)

于 2012-10-01T06:54:50.190 回答