0
我已經在viewDidLoad中聲明瞭一個數組。指定一個單個字符串的數組,然後在修改它之後獲取它的值
-(void) viewDidLoad{
status=[[NSMutableArray alloc] init];
[status addObject:@"Pending"];
}
現在在某些功能中,我需要將「Pending」的值更改爲「Approved」。然後在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
根據我你需要使用NSMutableDictionary而不是數組,然後檢查狀態鍵的值。 –