I am doing a project in Objective-C so when I create a custom xib and connect a couple of outlets, it gives me the error:
2023-06-07 22:50:32.194106-0700 ProturisApp[91070:2437111] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<InputCollectionViewCell 0x10403ee78> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key brickWall.'
These are my classes and my extension:
@implementation UIView (NIBLoader)
+ (instancetype)fromNib {
return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] objectAtIndex:0];
}
@end
#import "InputCollectionViewCell.h"
#define IDENTIFFIER @"InputCollectionViewCell"
@implementation InputCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self loadFromNib];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self loadFromNib];
self.userInteractionEnabled = YES;
// Initialize what is needed
}
return self;
}
+ (NSString *) identifier {
return IDENTIFFIER;
}
- (void)loadFromNib {
UIView *nibView = [[self class] fromNib];
if (nibView) {
nibView.frame = self.bounds;
nibView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:nibView];
nibView.backgroundColor = [UIColor redColor];
}
}
@end
#import "MainViewController.h"
@interface MainViewController ()
@end
@implementation MainViewController
@synthesize menuCollectionView;
- (void)viewDidLoad {
[super viewDidLoad];
[self.menuCollectionView registerClass:[InputCollectionViewCell class] forCellWithReuseIdentifier:[InputCollectionViewCell identifier]];
menuCollectionView.delegate = self;
menuCollectionView.dataSource = self;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[InputCollectionViewCell dealloc];
}
- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {
// Dequeue a reusable cell from the collection view.
InputCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[InputCollectionViewCell identifier] forIndexPath:indexPath];
[cell addBorderAndShadow];
// Configure the cell with data for the index path.
// MyData *data = self.myDataArray[indexPath.item];
// [cell configureWithData:data];
// Return the configured cell.
return cell;
}