IBOutletsとして使用したいUILabelが30個あります。ただし、UILabelプロパティにアクセスしようとすると、タイプ'id'のオブジェクトのプロパティxが見つからないというエラーが表示されます。私はObjectiveCに非常に錆びているので、根本的に間違ったことをしたのではないかと思います。すべてのラベルをxibファイル内のIBCollectionに割り当てました。
.h
@interface ViewController : UIViewController
{
IBOutletCollection(UILabel) NSArray *statPanels;
}
@property(retain) IBOutletCollection(UILabel) NSArray *statPanels;
@end
.m
@interface ViewController ()
@end
@implementation ViewController
@synthesize statPanels;
- (void)viewDidLoad
{
[super viewDidLoad];
statPanels = [[NSArray alloc] initWithObjects:[UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], [UILabel alloc], nil ];
[statPanels objectAtIndex:3].hidden = YES;
}