Objective c NSMutableSet of buttons错误“NSMutableSet”不是受支持的集合类。NSArray的期望子类

Objective c NSMutableSet of buttons错误“NSMutableSet”不是受支持的集合类。NSArray的期望子类,objective-c,cocoa-touch,Objective C,Cocoa Touch,我认为这很直截了当,但我不确定我做错了什么。 我试图给多个按钮一个边框,尽管我不断得到一个错误: “NSMutableSet”不是受支持的集合类。期望子类 当然可以 以下是我在.h文件中的代码: @property (retain, nonatomic) IBOutletCollection(UIButton) NSMutableSet* btn; 我已将此链接到我的XIB上的按钮 在我的.m文件中,我将其放置在viewDidLoad中: - (void)viewDidLoad { [

我认为这很直截了当,但我不确定我做错了什么。 我试图给多个按钮一个边框,尽管我不断得到一个错误:

“NSMutableSet”不是受支持的集合类。期望子类 当然可以

以下是我在.h文件中的代码:

@property (retain, nonatomic) IBOutletCollection(UIButton) NSMutableSet* btn;
我已将此链接到我的XIB上的按钮

在我的.m文件中,我将其放置在viewDidLoad中:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    for (UIButton *b in self.btn) {

        b.layer.borderWidth=1.0f;
        b.layer.borderColor=[[UIColor blackColor] CGColor];
    }

}

如果您能提供帮助,谢谢您。

我知道了,但是有没有更简洁的方法在.m文件中编写代码

以下是.h文件代码:

@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *btn;
在.m文件中,我执行了以下操作:

for (int i=0; i < [self.btn count]; i++)
{
    [[[self.btn objectAtIndex:i]layer] setBorderWidth:1.0f];

    [[[self.btn objectAtIndex:i]layer] setBorderColor:[UIColor blackColor].CGColor ];        
}

AFAIK IBMoutletCollection只能与NSArray和NSMutableArray一起使用。您是否尝试相应地更改btw?我尝试更改为NSArray和NsMutableArray,但出现了相同的错误。self.btn[I]。borderColor=UIColor.blackColor.CGColor@GerdK,你失去了图层属性访问权限。Gerard,因为您对层做了两件事,您可能希望为它创建一个本地代码:CALayer*layer=self.btn[i].layer;layer.borderWidth=1;layer.borderColor=。。。;或者使用快速枚举抱歉,格式在注释中丢失:forUIButton*按钮位于btn{button.layer.borderWidth=1.0f;button.layer.borderColor=UIColor.blackColor.CGColor;}
    [[[self.btn objectAtIndex:i]layer] 
     setBorderColor:[UIColor blackColor].CGColor ];