所以我有一个NSMutanbleArray(称为用户),实际上我无法在其上使用addObject方法。
这是我的代码:
#import "GroupRestBeans.h"
#import "User.h"
@interface GroupRestBeans()
@property(strong,nonatomic)NSString *name;
@property(strong,nonatomic)NSMutableArray<User *> *users;
@end
@implementation GroupRestBeans
-(instancetype)init{
self = [super init];
if (self) {
_users = [[NSMutableArray alloc] init];
}
return self;
}
-(void)newUser:(User *)user{
[self.users addObject:user]; //Here there is an error:
//No visible @interface for 'NSArray' declares the selector 'addObject:'
}
- (NSArray *)users {
return _users;
}
@end
我不知道为什么,而且我在其他班级做同样的事情...... 如果有人可以提供帮助,我会很感激,提前谢谢:)