NSMutableArray是不是替换对象?

时间:2013-01-14 22:05:02

标签: iphone ios ipad

我想替换NSMutableArray对象中的数组对象。 我从oldArray获取_alertsArray并更改其值,并希望将oldArray替换为newArray。但是没有效果!!

NSArray *oldArray = (NSArray *)[_alertsArray objectAtIndex:[indexPath row]];
NSMutableArray *newArray = [[NSMutableArray alloc] initWithArray:oldArray copyItems:YES];
[newArray replaceObjectAtIndex:3 withObject:@"YES"];
[_alertsArray replaceObjectAtIndex:[indexPath row] withObject:newArray];

1 个答案:

答案 0 :(得分:0)

NSMutableArray *newArray = [_alertsArray mutableCopy];
[newArray replaceObjectAtIndex:3 withObject:@"YES"];
_alertsArray = newArray;