MohanRaj S MohanRaj S - 1 year ago 173
iOS Question

UITableView error "Could not load NIB in bundle:" for custom cell

When I try with the following coding for custom cell, Its showing error.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *simpleTableIdentifier = @"SimpletablcellCell";
SimpletablcellCell *cell = (SimpletablcellCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpletablcellCell" owner:self options:nil];
cell = [nib objectAtIndex:0];

cell.nameLabel.text = [ar objectAtIndex:indexPath.row];
cell.thumbnailImageView.image = [UIImage imageNamed:[ar1 objectAtIndex:indexPath.row]];
cell.prepTimeLabel.text = [ar objectAtIndex:indexPath.row];

return cell;

Error msg

'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/apple/Library/Application Support/iPhone Simulator/6.0/Applications/FE02B3A1-C40C-4FAC-BBA6-B245350F3754/> (loaded)' with name 'SimpletablcellCell''
*** First throw call stack:
(0x1c8f012 0x10cce7e 0x1c8edeb 0x22ffac 0x23198d 0x3418 0xcef4b 0xcf01f 0xb780b 0xc819b 0x6492d 0x10e06b0 0x228bfc0 0x228033c 0x228beaf 0x1038cd 0x4c1a6 0x4acbf 0x4abd9 0x49e34 0x49c6e 0x4aa29 0x4d922 0xf7fec 0x44bc4 0x44dbf 0x44f55 0x4df67 0x2d40 0x117b7 0x11da7 0x12fab 0x24315 0x2524b 0x16cf8 0x1beadf9 0x1beaad0 0x1c04bf5 0x1c04962 0x1c35bb6 0x1c34f44 0x1c34e1b 0x127da 0x1465c 0x29fd 0x2925)
libc++abi.dylib: terminate called throwing an exception

Please check, what is wrong with this code?

Answer Source

Does a .nib / .xib exist in your project named SimpletablcellCell? You might have a typo in the name, please check carefully.

Make sure the file is part of your target. You can check this by opening the right-side menu in Xcode. Example:

file target settings

If the cell exists, is it being copied in the build process? Check the "Copy bundle resources" phase in your project target build settings and make sure it is being copied. If not, add the file manually to this phase.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download