Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Akagi010

macrumors newbie
Original poster
Sep 7, 2010
5
0
Hello,

I discovered a serious error in my app and after some time of analysing I have no idea how to fix it.

The app I work on crashes periodically with an error message like:

Code:
2011-01-18 20:02:11.156 MeetingProtocol[1583:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/E28E05D6-683B-4900-9815-1EC761079E43/MeetingProtocol.app> (loaded)' with name 'MeetingProtocolParticipantCell''
*** Call stack at first throw:
(
	0   CoreFoundation                      0x3587a987 __exceptionPreprocess + 114
	1   libobjc.A.dylib                     0x34a8249d objc_exception_throw + 24
	2   CoreFoundation                      0x3587a7c9 +[NSException raise:format:arguments:] + 68
	3   CoreFoundation                      0x3587a803 +[NSException raise:format:] + 34
	4   UIKit                               0x3438e783 -[UINib instantiateWithOwner:options:] + 1110
	5   UIKit                               0x3438fb39 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 92
	6   MeetingProtocol                     0x0001013b -[MeetingProtocolViewController tableView:cellForRowAtIndexPath:] + 1874
	7   UIKit                               0x3420ea21 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 516
	8   UIKit                               0x3420e7f3 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 34
	9   UIKit                               0x3420cd2d -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 936
	10  UIKit                               0x3420bedd -[UITableView layoutSubviews] + 140
	11  UIKit                               0x341b80cf -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 26
	12  CoreFoundation                      0x35818bbf -[NSObject(NSObject) performSelector:withObject:] + 22
	13  QuartzCore                          0x31075685 -[CALayer layoutSublayers] + 120
	14  QuartzCore                          0x3107543d CALayerLayoutIfNeeded + 184
	15  QuartzCore                          0x3106f56d _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 212
	16  QuartzCore                          0x3106f383 _ZN2CA11Transaction6commitEv + 190
	17  QuartzCore                          0x31092f9d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 52
	18  CoreFoundation                      0x3580ac59 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
	19  CoreFoundation                      0x3580aacd __CFRunLoopDoObservers + 412
	20  CoreFoundation                      0x358020cb __CFRunLoopRun + 854
	21  CoreFoundation                      0x35801c87 CFRunLoopRunSpecific + 230
	22  CoreFoundation                      0x35801b8f CFRunLoopRunInMode + 58
	23  GraphicsServices                    0x320c84ab GSEventRunModal + 114
	24  GraphicsServices                    0x320c8557 GSEventRun + 62
	25  UIKit                               0x341dc329 -[UIApplication _run] + 412
	26  UIKit                               0x341d9e93 UIApplicationMain + 670
	27  MeetingProtocol                     0x00002887 main + 70
	28  MeetingProtocol                     0x0000283c start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
Data Formatters unavailable (Error calling dlopen for: "/Developer/usr/lib/libXcodeDebuggerSupport.dylib": "dlopen(/Developer/usr/lib/libXcodeDebuggerSupport.dylib, 10): no suitable image found.  Did find:
	/Developer/usr/lib/libXcodeDebuggerSupport.dylib: open() failed with errno=24
	/Developer/usr/lib/libXcodeDebuggerSupport.dylib: stat() failed with errno=554240")
kill
quit

The Debugger has exited with status 0.

This problem happens with other NIB files, too, usually table view cells I designed with the interface builder.

There are two way for me to load the cells:

1. For cells that are linked to one table view: I add an IBOutlet to the table view controller and link the cell via IB to this outlet. Then I call [[NSBundle mainBundle] loadNibNamed: ...]. Then I simply get the cell from the outlet.

2. For cells I use in different table views: I call [[NSBundle mainBundle] loadNibNamed: ...] directly and evaluate the returned array of NIBs. Usually I get the first one.

Both of these ways fail.

I have no idea, what causes the problem and how to fix it, especially since the app works perfectly at the beginning (with the mentioned NIB files loaded).

Any ideas?

Best regards!
 
It might be that some nib files aren't being built with the target you are running. You can drag nib files to the target in the project and make sure they are linked.
 
Same Problem

Code:
2011-04-27 11:46:32.318 Directory[439:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/42009101-B0D3-46C3-9EFA-2A5FF69D2965/Directory.app> (loaded)' with name 'HierarchyCell''
*** Call stack at first throw:
(
	0   CoreFoundation                      0x359bb64f __exceptionPreprocess + 114
	1   libobjc.A.dylib                     0x35514c5d objc_exception_throw + 24
	2   CoreFoundation                      0x359bb491 +[NSException raise:format:arguments:] + 68
	3   CoreFoundation                      0x359bb4cb +[NSException raise:format:] + 34
	4   UIKit                               0x362fca53 -[UINib instantiateWithOwner:options:] + 1110
	5   UIKit                               0x362fde09 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 92
	6   Directory                           0x00006a63 -[DetailViewController tableView:cellForRowAtIndexPath:] + 294
	7   UIKit                               0x361549ed -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 516
	8   UIKit                               0x3615476b -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 34
	9   UIKit                               0x3614d0cd -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 936
	10  UIKit                               0x3614c27d -[UITableView layoutSubviews] + 140
	11  UIKit                               0x360f85fb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 26
	12  CoreFoundation                      0x35928f03 -[NSObject(NSObject) performSelector:withObject:] + 22
	13  QuartzCore                          0x31147bb5 -[CALayer layoutSublayers] + 120
	14  QuartzCore                          0x3114796d CALayerLayoutIfNeeded + 184
	15  QuartzCore                          0x3114d1c5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 212
	16  QuartzCore                          0x3114cfd7 _ZN2CA11Transaction6commitEv + 190
	17  QuartzCore                          0x31146055 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 56
	18  CoreFoundation                      0x35992a35 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
	19  CoreFoundation                      0x35994465 __CFRunLoopDoObservers + 412
	20  CoreFoundation                      0x3599575b __CFRunLoopRun + 854
	21  CoreFoundation                      0x35925ec3 CFRunLoopRunSpecific + 230
	22  CoreFoundation                      0x35925dcb CFRunLoopRunInMode + 58
	23  GraphicsServices                    0x30c5f41f GSEventRunModal + 114
	24  GraphicsServices                    0x30c5f4cb GSEventRun + 62
	25  UIKit                               0x36121d69 -[UIApplication _run] + 404
	26  UIKit                               0x3611f807 UIApplicationMain + 670
	27  Directory                           0x00002c4b main + 70
	28  Directory                           0x00002c00 start + 40
)
terminate called after throwing an instance of 'NSException'

I'm running into a similar problem... This is coming from a UITableView with a custom cell, and the scrolling process works for a while, loading from the nib, but then fails to find the nib a scroll or two later and crashes.

Any thoughts?
 
What version of Xcode are you using? There's some problem with Xcode 4 where it changes the file type of xib files resulting in various problems. This is mentioned in the Release Notes for Xcode 4.
 
I'm using 3.2.6, staying away from 4 for the time being. The File Type is file.xib.

A little further into the issue, it's definitely a memory issue, drawing a low mem warning after I scroll up and down six times. There are only 30 items in the list... no allocs, but a lot of array-access ops like this:
Code:
NSString* theAreaCityCode = [NSString stringWithString:[thePhoneRecs objectAtIndex:3]];
 
The Code:
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    int row = indexPath.row, x;
    static NSString *CellIdentifier = @"HierarchyCell";
	int totalRows = theApp.employeeSuperiorsRecords.count + theApp.employeeSubordinateRecords.count + kEmployee;
	
	int codenum;
	NSArray *thePhoneRecs, *thisRec;
	NSString *theAreaCityCode, *theAccessCodeID, *thePhoneNum, *countryAccessNum, *combinedPhoneNum, *fullName;
	NSNumber *theAccessCodeNum;
	CGRect curNameLableFrame;
	
	HierarchyCell *cell = (HierarchyCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
	{
        //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
		NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed: @"HierarchyCell" owner:self options:nil];
		for (id currentObject in nibObjects)
		{
			if ([currentObject isKindOfClass:[HierarchyCell class]])
			{
				cell = (HierarchyCell *)currentObject;
				cell.selectionStyle = UITableViewCellSelectionStyleBlue;
			}
		}
	}
	else 
	{
		cellRecycle++;
		cell.lblHierName.frame = masterNameCell;
	}
    
	if (row >= 0 && row < theApp.employeeSuperiorsRecords.count)
	{
		thisRec = [theApp.employeeSuperiorsRecords objectAtIndex:row];
		
		curNameLableFrame = cell.lblHierName.frame;
		x = curNameLableFrame.origin.x + kTabSpace * row;
		curNameLableFrame.origin.x = x;
		curNameLableFrame.size.width = curNameLableFrame.size.width - x;
		cell.lblHierName.frame = curNameLableFrame;
		fullName = [NSString stringWithString:[theApp.utilTools UTIL_FormatNameStr:[thisRec objectAtIndex:2] :[thisRec objectAtIndex:4] :[thisRec objectAtIndex:5]]];
		cell.lblHierName.text = fullName;
		cell.lblHierName.hidden = NO;
		cell.lblHierName.textColor = [UIColor lightGrayColor];

		cell.lblHierPosition.text = [thisRec objectAtIndex:10];
		cell.lblHierPosition.hidden = NO;
		
		[theApp.employeeHierarchyPhoneRecords removeAllObjects];
		[theApp.sqlTools SQL_GetEmployeePhoneDataFromEmployeeGUID:[thisRec objectAtIndex:1] :[theApp employeeHierarchyPhoneRecords]];
		if (theApp.employeeHierarchyPhoneRecords.count > 0)
		{
			thePhoneRecs = [theApp.employeeHierarchyPhoneRecords objectAtIndex:0];
			theAreaCityCode = [NSString stringWithString:[thePhoneRecs objectAtIndex:3]];
			theAccessCodeID = [NSString stringWithString:[thePhoneRecs objectAtIndex:2]];
			thePhoneNum = [NSString stringWithString:[thePhoneRecs objectAtIndex:4]];
			codenum = [theAccessCodeID intValue];
			theAccessCodeNum = [NSNumber numberWithInt:codenum];
			
			 // this call retrieves the countryCodeRecord
			[theApp.sqlTools SQL_GetDataFromCountryAccessCodeId:theAccessCodeNum];
			countryAccessNum = [NSString stringWithString:[theApp.countryCodeRecord objectAtIndex:0]];
			
			combinedPhoneNum = [NSString stringWithFormat:@"+%@ %@ %@", countryAccessNum, theAreaCityCode, thePhoneNum];
			cell.lblHierPhone.text = combinedPhoneNum;
			cell.lblHierPhone.hidden = NO;
		}
	}
	else if (row == theApp.employeeSuperiorsRecords.count)
	{
		curNameLableFrame = cell.lblHierName.frame;
		x = curNameLableFrame.origin.x + kTabSpace * row;
		
		curNameLableFrame.origin.x = x;
		curNameLableFrame.size.width = curNameLableFrame.size.width - x;
		cell.lblHierName.frame = curNameLableFrame;
		
		self.theEmployeeOfficePhone;
		cell.lblHierName.text = self.lblMainName.text;
		cell.lblHierPosition.text = self.lblPosition.text;
		cell.lblHierPhone.text = self.theEmployeeOfficePhone;;
		cell.lblHierName.hidden = NO;
		cell.lblHierPosition.hidden = NO;
		cell.lblHierPhone.hidden = NO;
		cell.lblHierName.textColor = [UIColor darkGrayColor];
	}
	else if (row > theApp.employeeSuperiorsRecords.count && row < totalRows)
	{

		int adjustedRow = row - (theApp.employeeSuperiorsRecords.count + kEmployee);
		thisRec = [theApp.employeeSubordinateRecords objectAtIndex:adjustedRow];
		
		curNameLableFrame = cell.lblHierName.frame;
		x = curNameLableFrame.origin.x + ((theApp.employeeSuperiorsRecords.count + 1) * kTabSpace);
		curNameLableFrame.origin.x = x;
		curNameLableFrame.size.width = curNameLableFrame.size.width - x;
		cell.lblHierName.frame = curNameLableFrame;
		fullName = [NSString stringWithString:[theApp.utilTools UTIL_FormatNameStr:[thisRec objectAtIndex:2] :[thisRec objectAtIndex:4] :[thisRec objectAtIndex:5]]];
		cell.lblHierName.text = fullName;
		cell.lblHierName.hidden = NO;
		cell.lblHierName.textColor = [UIColor lightGrayColor];
		
		cell.lblHierPosition.text = [thisRec objectAtIndex:10];
		cell.lblHierPosition.hidden = NO;
		
		[theApp.employeeHierarchyPhoneRecords removeAllObjects];
		[theApp.sqlTools SQL_GetEmployeePhoneDataFromEmployeeGUID:[thisRec objectAtIndex:1] :[theApp employeeHierarchyPhoneRecords]];
		if (theApp.employeeHierarchyPhoneRecords.count > 0)
		{
			thePhoneRecs = [theApp.employeeHierarchyPhoneRecords objectAtIndex:0];
			theAreaCityCode = [NSString stringWithString:[thePhoneRecs objectAtIndex:3]];
			theAccessCodeID = [NSString stringWithString:[thePhoneRecs objectAtIndex:2]];
			thePhoneNum = [NSString stringWithString:[thePhoneRecs objectAtIndex:4]];
			codenum = [theAccessCodeID intValue];
			theAccessCodeNum = [NSNumber numberWithInt:codenum];
			
			// this call retrieves the countryCodeRecord
			[theApp.sqlTools SQL_GetDataFromCountryAccessCodeId:theAccessCodeNum];
			countryAccessNum = [NSString stringWithString:[theApp.countryCodeRecord objectAtIndex:0]];
			
			combinedPhoneNum = [NSString stringWithString:[NSString stringWithFormat:@"+%@ %@ %@", countryAccessNum, theAreaCityCode, thePhoneNum]];
			cell.lblHierPhone.text = combinedPhoneNum;
			cell.lblHierPhone.hidden = NO;
		}
	}
	
    return cell;
}

I'm validating the reuse so that isn't an issue.

Thanks very much for looking.
 
Last edited:
I looked over the source code and I don't see anything obvious that would cause the indicated problem.

This problem has been reported by others but I didn't see any case where a post resolved the problem with a clear description of why it happened and what the correct solution is.

I'm not certain what the best way to proceed is but here are some suggestions. You mention that your app gets a memory warning. It is possible that running out of memory prevents UINib from loading the nib correctly. It's also possible that your app has a bug that's revealed when a memory warning occurs and that bug causes this problem. You might want to use the Sim and see if simulated memory warnings cause this problem to occur and if so see what the problem is in your code. You might also use Instruments to see why your app is getting memory warnings.

I think it's possible that your app is corrupting memory and that causes this problem. Memory corruption is a hard bug to track down. There are some tools called malloc debug that you can probably use in the Sim to further track this down.

You should of course use Build and Analyze to check your code and also run with NSZombies to look for certain kinds memory errors.
 
Once again, thanks for looking it over. I was hoping for a 13-yo to catch something... "Hey DA, look at that!":eek:

The only one of your suggestions which I haven't used on this memory problem is NSZombies, so maybe that will give a clue. You are correct that the nib can't load because of low memory.

When I find the solution, I'll post back.

Best, Roon
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.