NSInternalInconsistencyException', reason: 'Could not load NIB in bundle while fetching 500+ records from the address book database

孤街醉人 提交于 2020-01-01 14:59:29

问题


I am sorry if this question is getting repeated, but I could not help it since I have tried every possible solution but nothing worked and hence I am asking this question.

I am loading almost 500 records in my table view from the address book database at one go. If the records are few ,say 50 or 100, my table is displayed without any problem. But when the number of record goes say 300+, I get a crash which says:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'GroupmemberCell''

I have read some other forms which have solutions like checking in the Build Phase for the file or checking in the package content of the iOS app. I have tried everything and nothing works the file is present in the build phase and also gets added in the package content of my app file. Also I have removed these files once, i.e I deleted them entirely and created a new class of UITableViewCell, but then too the crash was present.

GroupmemberCell is an xib which I have added in my table view.Below is the code snippet from the cell for row datasource method.

static NSString *CellIdentifier = @"Cell";
    GroupmemberCell   *cell = (GroupmemberCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];;
    if (cell == nil)
    {

        NSArray *cellxibfilepath = [[NSBundle mainBundle]loadNibNamed:@"GroupmemberCell" owner:self options:nil];

        if  (cellxibfilepath)
        {

        for(id cellObjects in cellxibfilepath)
        {
            if ([cellObjects isKindOfClass:[UITableViewCell class]])
            {
                cell = (GroupmemberCell*)cellObjects;
            }

        }
        }
    }

What could be the problem here like the same code works for a record set of 100 without any crash but will give a crash if i fetch a set of 500+ records and display them in the table.

To fetch the records i am not giving any calls in the background, I have tried once but then too the crash was not solved.

My Thoughts: I think I am loading lots of data at once which might be giving few issues in the main thread for UI creation, because I do get the data in my arrays and I check them and then only I give command to reload the table.

 if (tableReloadArray.count!=0) {
             [objtable reloadData];
        }

I have seen in many apps that they load 1000+ data lightning speed - how are they doing it? What is their approach or is there any best practice that I am missing, please guide me out.


回答1:


After lots of brain storming sessions and drinking lots of coffees i used the "Analyse tool" cleared all the memory warnings and then used the "Instruments tool" to see if there were any leaks cleared them as well. Removed the derived data and cleaned the application and i was done.

There were round about 67 issues all over the application which the "Analyse tool" came up with and over 3-4 issues that the "Instrument tool" displayed

I know this may sound stupid but i got my crash resolved by doing this. Hope this helps someone who is stuck in the same problem.



来源:https://stackoverflow.com/questions/14814629/nsinternalinconsistencyexception-reason-could-not-load-nib-in-bundle-while-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!