I need help understanding why my console returns the error:
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle <--APP_LOCATION--> (loaded)' with name 'MyListingsTableViewCell'' ** First throw call stack: ...
I'm new to using these prototype cells and tables, I will attach the code below. I appreciate any support that you can offer.
Code for the view controller where the prototype cell is implemented as follow:
#import "MyListings.h"
@interface MyListings ()
@property (weak, nonatomic) IBOutlet UIButton *createListingButton;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@end
@implementation MyListings
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"MyListingsTableViewCell"];
UINib *nib1 = [UINib nibWithNibName:@"MyListingsTableViewCell" bundle:nil];
[self.tableView registerNib:nib1 forCellReuseIdentifier:@"MyListingsTableViewCell"];
titles = [[NSArray alloc]initWithObjects:@"1",@"2", nil];
currentBids = [[NSArray alloc]initWithObjects:@"3",@"4", nil];
stillAvailables = [[NSArray alloc]initWithObjects:@"5",@"6", nil];
_createListingButton.layer.cornerRadius = 8;
_createListingButton.layer.borderWidth = 1.5f;
_createListingButton.layer.borderColor = [UIColor whiteColor].CGColor;
[_createListingButton addTarget:self action:@selector(createListingButtonHighlightBorder) forControlEvents:UIControlEventTouchDown];
[_createListingButton addTarget:self action:@selector(createListingButtonUnhighlightBorder) forControlEvents:UIControlEventTouchUpInside];
[_createListingButton addTarget:self action:@selector(createListingButtonUnhighlightBorder) forControlEvents:UIControlEventTouchDragExit];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)createListingButtonHighlightBorder
{
_createListingButton.layer.borderColor = [UIColor colorWithRed:0.61 green:0.00 blue:0.02 alpha:1.0].CGColor;
}
- (void)createListingButtonUnhighlightBorder
{
_createListingButton.layer.borderColor = [UIColor whiteColor].CGColor;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [titles count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyListingsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyListingsTableViewCell" forIndexPath:indexPath];
[cell updateCellWithTitle:[titles objectAtIndex:indexPath.row] currentBid:[currentBids objectAtIndex:indexPath.row] stillAvailable:[stillAvailables objectAtIndex:indexPath.row]];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
Prototype Cell class:
- (void)awakeFromNib
{
[super awakeFromNib];
// Initialization code
}
- (void)updateCellWithTitle:(NSString *)title currentBid:(NSString *)bid stillAvailable:(NSString *)available
{
self.titleLabel.text = title;
self.currentBidLabel.text = bid;
self.stillAvailableLabel.text = available;
self.editLabel.text = @"Press to edit";
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}