这是错误的版本:
for (AddressPerson *perName in array) {
if ([[perName name] isEqualToString:@"Zhangsan"]) {
[array removeObject:perName];
}
正确的代码:
for (AddressPerson *perName in array.copy) {
if ([[perName name] isEqualToString:@"Zhangsan"]) {
[array removeObject:perName];
}
只要在原来的代码上加上一个单词就可以了~
网友评论