Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 9, 2008, 07:27 AM   #1
Littleodie914
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Broke My UITableViewCell, Can't Fix It! :(

Hey guys, this is more a shot in the dark than anything else, I made a few changes to my UITableViewCell code, and began receiving the following error *after a value was added to the tableview, and after it was told to reload data.*

The sequence is:

1) Modal window opens
2) User clicks a "create" button"
3) The creation, addition, and data reloading occurs
4) The tableview "below" the modal window is re-displayed

Problem 4 is where the error occurs, but since there's no user-accessible code to trace through and find the error, I'm a bit stuck. Here's what I'm getting:

Code:
Code Type:       X86 (Native)
Parent Process:  launchd [112]

Date/Time:       2008-04-09 08:23:39.342 -0400
OS Version:      Mac OS X 10.5.2 (9C7010)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000fffffffc
Crashed Thread:  0

Thread 0 Crashed:
0   UIKit                         	0x30c70a4d -[UITableViewRowData rectForRow:inSection:] + 188
1   UIKit                         	0x30b5110f -[UITableView(_UITableViewPrivate) _adjustExtraSeparators] + 392
2   UIKit                         	0x30b47bab -[UITableView layoutSubviews] + 110
3   QuartzCore                    	0x0018070b -[CALayer layoutSublayers] + 50
4   QuartzCore                    	0x00180635 CALayerLayoutIfNeeded + 172
Do you guys know of any way to debug this error, or to figure out which of the arguments being passed to the UITableViewRowData object are problematic? Or what values are being passed back at all? Thanks!
Littleodie914 is offline   0 Reply With Quote
Old Apr 9, 2008, 07:48 AM   #2
Spike099
macrumors regular
 
Join Date: Feb 2007
Location: Canada
Whenever i've seen the EXEC_BAD_ACCESS, it's been caused by myself releasing and freeing an object too soon, and later trying to access/send it a message. My advice is to check your properties, make sure their retained properly and of course released when they need to be.
__________________
MacBook 4GBRam 320GBHDD
iMac 20" 4GBRam 1TBHDD
iPhone 16GB
Cocoa Developer
Spike099 is offline   0 Reply With Quote
Old Apr 9, 2008, 08:46 AM   #3
cmaier
macrumors G3
 
Join Date: Jul 2007
Location: California
it would be a lot easier to diagnose if you showed us the interesting bits of code.
cmaier is offline   0 Reply With Quote
Old Apr 9, 2008, 09:42 AM   #4
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Quote:
Originally Posted by cmaier View Post
it would be a lot easier to diagnose if you showed us the interesting bits of code.
That's the thing, this is "internal" code. I have no access to the line of code where the error occurs, thus I have no access to the variables being passed to the rectForRow:inSection: method.

That's what I'm ultimately trying to determine: Is there any way to view this section of code, or debug it in any way?

Edit: As a bit more clarification, there's a "Done" button at the top of my modal window, which when pressed, executes the following code:

Code:
- (void)createSubject:(id)sender {
	NSLog(@"1");
	if ([titleTextField text] != nil)
		[tempSubject setTitle:[titleTextField text]];
	else
		[tempSubject setTitle:@"New Subject"];
	NSLog(@"2");
	if ([noteTextField text] != nil && [noteTextField text] != @"" && [noteTextField text] != @" ")
		[tempSubject setNote:[noteTextField text]];
	NSLog(@"3");
	[tempSubject setHue:[colorSlider value]];
	[tempSubject setAssignments:[[NSMutableArray alloc] init]];
	NSLog(@"4");
	[APP_DELEGATE.subjects addObject:tempSubject];
	NSLog(@"5");
	[[((IPM_SubjectsViewController *)[[APP_DELEGATE.firstNavigationController viewControllers] objectAtIndex:0]) subjectsTableView] reloadData];
	NSLog(@"6");
	[APP_DELEGATE.firstNavigationController dismissModalViewControllerAnimated:YES];
	NSLog(@"7");
}
This code all executes correctly, down to the printing of the 7. It is after this point that the app explodes, with the stack trace posted above. What, logically, should happen after the ModalViewController is dismissed? (So I know where I should look next.)

I can't seem to determine what changes in my code spurred the sudden error, but any help is appreciated.

Last edited by Littleodie914; Apr 9, 2008 at 10:23 AM.
Littleodie914 is offline   0 Reply With Quote
Old Apr 9, 2008, 10:58 AM   #5
cmaier
macrumors G3
 
Join Date: Jul 2007
Location: California
I'm more interested in the tableviewcell code you changed.

Remember that if you mess up memory in one piece of code, you can get a crash in a completely unrelated bit of code. I'm assuming that when you changed the tableviewcell code you ended up dealloc'ing something that is later used, or you used something that's never been alloc'd.
cmaier is offline   0 Reply With Quote
Old Apr 9, 2008, 12:06 PM   #6
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Wow, finally figured it out. I went through an older backup I had made, and compared the code line by line for changes. Turns out the erroneous stuff was in my App Delegate, in the following code:

Code:
//self.smartGroups = [[NSMutableArray alloc] init]; Old Code
		
// Begin New Code
		NSMutableArray *newGroups = [NSMutableArray new];
		IPM_ModelGroup *newGroup = [[IPM_ModelGroup alloc] initWithTitle:@"Spiffy Smart Group" subjects:[NSArray new] dayRange:7];
		IPM_ModelGroup *newGroup2 = [[IPM_ModelGroup alloc] initWithTitle:@"New Group" subjects:[NSArray new] dayRange:14];
		
		[newGroups addObject:newGroup];
		[newGroups addObject:newGroup2];
		
		self.smartGroups = newGroups;
// End New Code
Notice the commented out line of "Old Code." For some reason the tableview was unable to get the smart groups from the app delegate. Why would an object that had obviously been allocated an initialized cause an issue? (As the new code works fine.)
Littleodie914 is offline   0 Reply With Quote
Old Apr 9, 2008, 12:36 PM   #7
Sbrocket
macrumors 65816
 
Sbrocket's Avatar
 
Join Date: Jun 2007
Location: /dev/null
I guess you found the new -[UITableView dequeueReusableCellWithIdentifier:] method that replaced availableCell: on the tableView:cellForRowAtIndexPath: delegate method, then. My UITableView that I've been piecing together really started acting weird this time around with Beta 3 of the SDK. Selections don't seem to work if you don't use -[UITableView dequeueReusableCellWithIdentifier:] to recycle cells in tableView:cellForRowAtIndexPath:, and selecting something then scrolling ends up with some weird behavior too. Not to mention it'll select multiple cells. So confusing...I love API changes so much.
__________________

Unibody MBP 15" | 2.53GHz | 4GB DDR3 | 320GB @ 7200RPM
Sbrocket is offline   0 Reply With Quote
Old Apr 9, 2008, 12:49 PM   #8
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Littleodie914, I'd suggest not using new. It's kind of old school. Use alloc/init instead. Also, new returns an object with a retain count of 1 that is not autoreleased, so that code above is leaking memory. Instead of [NSMutableArray new] use [NSMutableArray array] which returns an autoreleased object.
kainjow is offline   0 Reply With Quote
Old Apr 9, 2008, 01:56 PM   #9
cmaier
macrumors G3
 
Join Date: Jul 2007
Location: California
Quote:
Originally Posted by Sbrocket View Post
I guess you found the new -[UITableView dequeueReusableCellWithIdentifier:] method that replaced availableCell: on the tableView:cellForRowAtIndexPath: delegate method, then. My UITableView that I've been piecing together really started acting weird this time around with Beta 3 of the SDK. Selections don't seem to work if you don't use -[UITableView dequeueReusableCellWithIdentifier:] to recycle cells in tableView:cellForRowAtIndexPath:, and selecting something then scrolling ends up with some weird behavior too. Not to mention it'll select multiple cells. So confusing...I love API changes so much.
Where (if anywhere) is that thing documented? Can't seem to find it in the docs xcode is using.
cmaier is offline   0 Reply With Quote
Old Apr 9, 2008, 02:32 PM   #10
Sbrocket
macrumors 65816
 
Sbrocket's Avatar
 
Join Date: Jun 2007
Location: /dev/null
Quote:
Originally Posted by cmaier View Post
Where (if anywhere) is that thing documented? Can't seem to find it in the docs xcode is using.
The docs aren't updated, but if you check the header files its there and its shown in the API Beta 2 to Beta 3 changes.
__________________

Unibody MBP 15" | 2.53GHz | 4GB DDR3 | 320GB @ 7200RPM
Sbrocket is offline   0 Reply With Quote
Old Apr 9, 2008, 09:45 PM   #11
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Quote:
Originally Posted by Sbrocket View Post
The docs aren't updated, but if you check the header files its there and its shown in the API Beta 2 to Beta 3 changes.
Does anyone know why the documentation isn't being updated? After all, that's where Xcode gets its auto-completion "dictionary," and it's pretty frustrating to have it tell you "Oh sure, I know what you mean!" and insert the rest of a method, only to find out it's deprecated and crashes your app.
Littleodie914 is offline   0 Reply With Quote
Old Apr 10, 2008, 01:10 AM   #12
Sbrocket
macrumors 65816
 
Sbrocket's Avatar
 
Join Date: Jun 2007
Location: /dev/null
Quote:
Originally Posted by Littleodie914 View Post
Does anyone know why the documentation isn't being updated? After all, that's where Xcode gets its auto-completion "dictionary," and it's pretty frustrating to have it tell you "Oh sure, I know what you mean!" and insert the rest of a method, only to find out it's deprecated and crashes your app.
Its been updated now. I seem to remember clicking update for a few doc sets earlier so it much just take them a day or so to get the doc updates out.
__________________

Unibody MBP 15" | 2.53GHz | 4GB DDR3 | 320GB @ 7200RPM
Sbrocket is offline   0 Reply With Quote
Old Apr 12, 2008, 08:56 AM   #13
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Quote:
Originally Posted by kainjow View Post
Littleodie914, I'd suggest not using new. It's kind of old school. Use alloc/init instead. Also, new returns an object with a retain count of 1 that is not autoreleased, so that code above is leaking memory. Instead of [NSMutableArray new] use [NSMutableArray array] which returns an autoreleased object.
Ah, thanks. I knew there was a small difference between the two, but I always thought "new" was just a convenience method.

Also, I ran into this same problem again, and it turns out a few of my properties had been declared with the nonatomic attribute, which was causing some reference/thread issues as well.
Littleodie914 is offline   0 Reply With Quote
Old Apr 17, 2008, 08:10 AM   #14
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Back again guys, running into the same issue. Now it's when I try to delete a row from my tableview. Here's the stacktrace:

Code:
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000fffffffc
Crashed Thread:  0

Thread 0 Crashed:
0   UIKit                         	0x30c95f1d -[UITableViewRowData rectForRow:inSection:] + 188
1   UIKit                         	0x30c954c8 -[UITableViewRowData rectForGlobalRow:] + 147
2   UIKit                         	0x30b6d9f2 -[UITableView(_UITableViewPrivate) _updateWithItems:withOldRowData:] + 11183
3   UIKit                         	0x30b622ba -[UITableView(_UITableViewPrivate) _endCellAnimations] + 644
4   iProcrastinate Mobile         	0x000044ac -[IPM_SubjectsViewController tableView:commitEditingStyle:forRowAtIndexPath:] + 768 (IPM_SubjectsViewController.m:148)
5   UIKit                         	0x30b697ed -[UITableView(UITableViewInternal) animateDeletionOfRowWithCell:] + 95
6   UIKit                         	0x30bb93d8 -[UIRemoveControl _doRemove:] + 199
7   UIKit                         	0x30b26e30 -[UIApplication sendAction:to:from:forEvent:] + 116
And here's the line of code that it's breaking at:

Code:
[subjectsTableView deleteRowsAtIndexPaths:pathArray withRowAnimation:UITableViewRowAnimationFade];
I'm getting confused. I have no idea how to debug something like this! Any tips would be greatly appreciated.
Littleodie914 is offline   0 Reply With Quote
Old Apr 17, 2008, 10:43 AM   #15
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Hmm, I just realized that after deleting a row, then adding new rows, I start seeing weird GUI inconsistencies as well.
Attached Thumbnails
Click image for larger version

Name:	Picture 2.png
Views:	17
Size:	29.0 KB
ID:	112548  
Littleodie914 is offline   0 Reply With Quote
Old Apr 23, 2008, 10:17 PM   #16
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Hmm... It seems like this might be an Apple bug? I built the *most basic* UITableView I could, and any reordering/deleting caused this flaw.

When I switch to a "Plain" table view, however (as opposed to a "Group" table view), there're no issues.

Edit: This issue remains unfixed in the new Beta 4 of the SDK, I've filed a bug report with Apple. If I hear anything back, I'll post it here.

Edit 2: Got an email back from Apple. It's a documented bug, and they're working on a fix.

Last edited by Littleodie914; Apr 30, 2008 at 09:28 AM.
Littleodie914 is offline   0 Reply With Quote
Old Jun 23, 2008, 02:55 PM   #17
blankmind
macrumors newbie
 
Join Date: Jun 2008
Has the deleteRowsAtIndexPaths:withAnimation bug been fixed?

Hello,

I am using the Beta 7 and have come across the problem you have described (tableView deleteRowsAtIndexPaths:withAnimation) when trying to delete table rows. It happens, for me, just with the top row (pretty much the same stack trace) - all other rows delete fine. Does this now work for you or is it still causing problems?

Any help with this would be greatly appreciated!
blankmind is offline   0 Reply With Quote
Old Jun 25, 2008, 04:05 AM   #18
sujithkrishnan
macrumors 6502
 
Join Date: May 2008
Location: Bangalore
Send a message via Yahoo to sujithkrishnan
Quote:
Originally Posted by Littleodie914 View Post
Hmm, I just realized that after deleting a row, then adding new rows, I start seeing weird GUI inconsistencies as well.
Hi.

I just want to know what image u used in ur view (screenshot u pasted) so as to get the iPhone native app look n feel??
Is that gradient is available???
I am searchiung for this background ...
Please help...
sujithkrishnan is offline   0 Reply With Quote
Old Jul 3, 2008, 07:41 AM   #19
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Quote:
Originally Posted by sujithkrishnan View Post
Hi.

I just want to know what image u used in ur view (screenshot u pasted) so as to get the iPhone native app look n feel??
Is that gradient is available???
I am searchiung for this background ...
Please help...
Hi.

If you're talking about the blue striped background, it's added automatically behind a grouped UITableView. I don't know if it's accessible outside of that.
Littleodie914 is offline   0 Reply With Quote
Old Jan 1, 2009, 10:06 AM   #20
rockman
macrumors newbie
 
Join Date: Jan 2009
Has anyone found the solution to this issue? I have the same problem,
multiple sections in a tableview and when numbofsections = 1, all is grand, but when > 1, crashed on delete.

Basically I have rows broken up into "months of the year", and I have tried returning static int, as well as dynamic int based on the actual months that are in the dataSource.


thanks in advance.
Rockman
rockman is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iOS 7.1 to Fix Geolocation Issue That Broke Location-Based Apps MacRumors iOS Blog Discussion 68 Mar 11, 2014 08:04 PM
I think I broke my AirPort / Bluetooth card. Can the local Apple store fix it? botsmack MacBook Pro 7 Sep 18, 2013 11:42 PM
mobile OSs: Acer gets it! "Android isn't broke so we won't try to fix it." ChazUK Alternatives to iOS and iOS Devices 10 Jun 15, 2013 07:33 AM
Early 08 MBP Just Broke... fix or buy new? gfish31 Buying Tips and Advice 25 Sep 6, 2012 06:50 PM
Custom Delete UITableViewCell mdhansen5 iPhone/iPad Programming 1 Jun 1, 2012 10:41 AM

Forum Jump

All times are GMT -5. The time now is 12:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC