[array removeObject:person];
数组中存的对象的地址,所以,array会根据地址判断是否是相同的对象,会删除整个数组中的所以指向person对象的地址;例如:
#import <Foundation/Foundation.h>
#import "Person.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
Person *person=[[Person alloc] init];
NSMutableArray *arr=[[NSMutableArray alloc] initWithObjects:person,person,@"dfsfs",nil];
[arr removeObject:person];
NSLog(@"%@",arr);
}
return 0;
}
打印结果:
2014-04-30 09:59:32.927 eqrewrwe[607:303] (
dfsfs
)
|