"declares the selector "addObject :"?-6ren"> "declares the selector "addObject :"?-我需要将员工的姓名插入数组,当我这样做时收到此错误。我的代码有什么问题? #import "Employee.h" @interface Organisation : NSObject -(void)-6ren">
gpt4 book ai didi

ios - 为什么我有错误 "No visible @interface for "NSArray"declares the selector "addObject :"?

转载 作者:行者123 更新时间:2023-11-28 18:02:45 26 4
gpt4 key购买 nike

我需要将员工的姓名插入数组,当我这样做时收到此错误。我的代码有什么问题?

#import "Employee.h"

@interface Organisation : NSObject

-(void) addEmployeeWithName:(NSString *)EmployeesName;

@end


@interface Organisation()

@property(strong, nonatomic) NSArray<Employee *> *employees;// private var

@end


@implementation Organisation

-(void) addEmployeeWithName:(NSString *)EmployeesName
{
[self.employees addObject:employeeName];// Error apear here
}


@end

最佳答案

NSArray是不可变的。你想使用 NSMutableArray .

关于ios - 为什么我有错误 "No visible @interface for "NSArray<Employee * >"declares the selector "addObject :"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39875103/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com