我有这样的课:
@interface MyObject : NSObject
@property (nonatomic, strong) NSString *type;
@end
我正在创建一个这样的数组:
NSMutableArray *array = [NSMutableArray array];
MyObject *obj = [[MyObject alloc] init];
obj.type = @"test1";
[array addObject:obj];
MyObject *obj2 = [[MyObject alloc] init];
obj2.type = @"test2";
[array addObject:obj2];
MyObject *obj3 = [[MyObject alloc] init];
obj3.type = @"test1";
[array addObject:obj3];
我想过滤数组以仅包含具有不同类型的对象,在我的示例中仅包含 obj1、obj2 并删除 obj3。