'NSArray' 没有可见的@interface 声明选择器'setTitle:forState:'
当我运行应用程序时,我发现只有一个错误,错误是 No visible @interface for 'NSArray' 声明选择器 'setTitle:forState:'
这是我的代码
< #import "CardGameViewController.h"
#import "PlayingCardDeck.h"
@interface CardGameViewController ()
@property (weak, nonatomic) IBOutlet UILabel *flipslabel;
@property(nonatomic) int flipCount;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *cardButtons;
@property (strong, nonatomic) Deck *deck;
@end
@implementation CardGameViewController
-(void)setCardButtons:(NSArray *)cardButtons
{
_cardButtons = cardButtons;
for (UIButton *cardButton in self.cardButtons){
Card *card = [self.deck drawRandomCard];
[cardButtons setTitle:card.contents forState:UIControlStateSelected];
}
}
- (Deck *)deck
{
if(!_deck) _deck=[[PlayingCardDeck alloc] init];
return _deck;
}
- (void)setFlipCount:(int)flipCount
{
_flipCount = flipCount;
self.flipslabel.text= [NSString stringWithFormat:@"Flips: %d", self. flipCount];
}
- (IBAction)flipCard:(UIButton *)sender
{
sender.selected=!sender.isSelected;
self.flipCount++;
}
@end
你认为错误是什么?