I am trying to use .xib files in iOS10+ in table View Controller again and again to load

 static NSString *reuseIdentifier = @"SessionTableViewCellIdentifier";

SessionTableViewCell *cell = (SessionTableViewCell*)[tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if( !cell )
{
    cell = [[[NSBundle mainBundle] loadNibNamed:@"SessionTableViewCell" owner:self options:nil] objectAtIndex:0];
}

It is working fine on Version 9.3 but after some time it gives me exception on iOS 10+

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/srtekappledemo/Library/Developer/CoreSimulator/Devices/1848F1BA-50B8-41AB-8538-CD741BD1A685/data/Containers/Bundle/Application/391AD08C-1DD7-46A0-A4D0-A07274A72241/ACSuccess.app> (loaded)' with name '3pB-ff-s9x-view-jo5-RS-cHl' and directory 'Main.storyboardc''
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e08fd4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010d6d021e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e0f92b5 +[NSException raise:format:] + 197
    3   UIKit                               0x000000010f342bd2 -[UINib instantiateWithOwner:options:] + 507
    4   UIKit                               0x000000010f0d69c5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
    5   UIKit                               0x000000010f0d72e7 -[UIViewController loadView] + 177
    6   UIKit                               0x000000010f0d761c -[UIViewController loadViewIfRequired] + 201
    7   UIKit                               0x000000010f0de062 -[UIViewController __viewWillAppear:] + 118
    8   UIKit                               0x000000010f1091d3 -[UINavigationController _startCustomTransition:] + 1290
    9   UIKit                               0x000000010f119e48 -[UINavigationController _startDeferredTransitionIfNeeded:] + 697
    10  UIKit                               0x000000010f11afdb -[UINavigationController __viewWillLayoutSubviews] + 58
    11  UIKit                               0x000000010f311dd7 -[UILayoutContainerView layoutSubviews] + 223
    12  UIKit                               0x000000010effaab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
    13  QuartzCore                          0x000000010d02ebf8 -[CALayer layoutSublayers] + 146
    14  QuartzCore                          0x000000010d022440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    15  QuartzCore                          0x000000010d0222be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    16  QuartzCore                          0x000000010cfb0318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
    17  QuartzCore                          0x000000010cfdd3ff _ZN2CA11Transaction6commitEv + 475
    18  UIKit                               0x000000010ef607f0 _afterCACommitHandler + 346
    19  CoreFoundation                      0x000000010e034267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    20  CoreFoundation                      0x000000010e0341d7 __CFRunLoopDoObservers + 391
    21  CoreFoundation                      0x000000010e018f8e __CFRunLoopRun + 1198
    22  CoreFoundation                      0x000000010e018884 CFRunLoopRunSpecific + 420
    23  GraphicsServices                    0x0000000111302a6f GSEventRunModal + 161
    24  UIKit                               0x000000010ef35c68 UIApplicationMain + 159
    25  ACSuccess                           0x000000010cbc08ff main + 111
    26  libdyld.dylib                       0x0000000111a7668d start + 1

but there are so many links for it I have tried almost everything, Stated below:

  1. Have you renamed your xib or storyboard file outside Xcode? If so, check everywhere you have a reference to it for inconsistencies. Also be sure you respect the uppercase / lowercase letters anywhere you reference the file since is case sensitive.

  2. Go to Interface Builder, select your View1 ViewController > Utilities Panel > Identity Inspector > check if the Custom Class corresponds to your ViewController Class if you have one (.h and .m files).

  3. Check your target's Build Phases > Copy Bundle Resources and make sure that your xib or storyboard file is added there. If you instantiate your View1 ViewController programmatically and you use xib file check the nib name for typos (remember, is case-sensitive). Also, if you currently append .xib file format to the name, remove the extension because it shouldn't be used. What I mean is this line of code: UIViewController *controller = [[UIViewController alloc] initWithNibName:@"xibFileName" bundle:nil];

  4. Check the properties of your xib or storyboard file in the file inspector and make sure that your file is linked to your target in the Target Membership selection panel.

  5. Check the properties of the xib or storyboard file in the file inspector and try switching your file Location to Relative to project or Relative to group. See if either way makes a difference.

  6. If you're adding your view controller programmatically in the initWithCoder then you should instantiate it in the viewDidLoad method instead

  7. If nothing from above applies to your situation, you could delete the file from Xcode (select Remove References) and import it again in your project.

  8. Check your Info.plist file. If you use storyboads, you should have an entry like Main storyboard file base name and NOT Main nib file base name. If you use nibs, then is vice-versa. Also check that the file base name corresponds with name of the actual file.

Am I missing memory leak which is creating it this query?

0

There are 0 answers