I’m currently smashing my head against a brick wall while trying to get my application back to work.
All i want to do is to show an UIActionSheet as soon as a row in my search tableview is being selected. Simple task one might think…it seems not.
When i start the application on the simulator, it SIGABRT’s before it even loaded the rootViewController (StackTrace below). I have absolutely no clue where to start digging.
My App’s delegate method “didFinishLaunchingWithOptions” runs through smoothly, the last breakpoint i can set in my code is this one:
OverviewViewController.m:
- (void)viewWillAppear:(BOOL)animated
{
// this it the last breakable line, jumping over it leads to the SIGABRT
[super viewWillAppear:animated];
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewItem:)];
[[self navigationItem] setRightBarButtonItem:addButton];
[addButton release];
}
OverviewViewController is my NavigationControllers rootViewController, both are initialized in the app’s delegate method didFinishLaunchingWithOptions.
AppDelegate.m
OverviewViewController *ovController = [[OverviewViewController alloc] init];
(omitting initialization code for ovController)
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:ovController];
[ovController release];
NSArray *tabViews = [NSArray arrayWithObjects:navController, (my other controllers), nil];
[navController release];
[tabController setViewControllers:tabViews];
[window setRootViewController:tabController];
The error started popping up after i started implementing a completely different view (SearchControllerView) using standard UITableViewDelegate and UITableViewDateSourceDelegate methods. This view is not even loaded on startup, only when a certain button is clicked.
StackTrace:
2011-01-08 13:22:21.279 ReleaseDate[5295:207] -[UITableView _saveOpaqueViewState:]: unrecognized selector sent to instance 0x502e000
2011-01-08 13:22:21.282 ReleaseDate[5295:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableView _saveOpaqueViewState:]: unrecognized selector sent to instance 0x502e000'
*** Call stack at first throw:
(
0 CoreFoundation 0x0118bbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x012e05c2 objc_exception_throw + 47
2 CoreFoundation 0x0118d6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x010fd366 ___forwarding___ + 966
4 CoreFoundation 0x010fcf22 _CF_forwarding_prep_0 + 50
5 UIKit 0x006745b3 -[UITableViewRowData initWithTableView:] + 285
6 UIKit 0x0052eae3 -[UITableView(_UITableViewPrivate) _updateRowData] + 84
7 UIKit 0x0052a6da -[UITableView numberOfSections] + 39
8 UIKit 0x006c25ee -[UITableViewController viewWillAppear:] + 100
9 ReleaseDate 0x00003364 -[OverviewViewController viewWillAppear:] + 68
10 UIKit 0x00579c9a -[UINavigationController _startTransition:fromViewController:toViewController:] + 858
11 UIKit 0x00574606 -[UINavigationController _startDeferredTransitionIfNeeded] + 266
12 UIKit 0x0068ce01 -[UILayoutContainerView layoutSubviews] + 226
13 QuartzCore 0x01f25451 -[CALayer layoutSublayers] + 181
14 QuartzCore 0x01f2517c CALayerLayoutIfNeeded + 220
15 QuartzCore 0x01f1e37c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
16 QuartzCore 0x01f1e0d0 _ZN2CA11Transaction6commitEv + 292
17 UIKit 0x004c019f -[UIApplication _reportAppLaunchFinished] + 39
18 UIKit 0x004c0659 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
19 UIKit 0x004cadb2 -[UIApplication handleEvent:withNewEvent:] + 1533
20 UIKit 0x004c3202 -[UIApplication sendEvent:] + 71
21 UIKit 0x004c8732 _UIApplicationHandleEvent + 7576
22 GraphicsServices 0x0199da36 PurpleEventCallback + 1550
23 CoreFoundation 0x0116d064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
24 CoreFoundation 0x010cd6f7 __CFRunLoopDoSource1 + 215
25 CoreFoundation 0x010ca983 __CFRunLoopRun + 979
26 CoreFoundation 0x010ca240 CFRunLoopRunSpecific + 208
27 CoreFoundation 0x010ca161 CFRunLoopRunInMode + 97
28 UIKit 0x004bffa8 -[UIApplication _run] + 636
29 UIKit 0x004cc42e UIApplicationMain + 1160
30 ReleaseDate 0x00002ac4 main + 102
31 ReleaseDate 0x00002a55 start + 53
)
terminate called after throwing an instance of 'NSException'
Can anybody help me getting on the right track? I’m really starting to go crazy on this one…
UPDATE
Implementation of cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"UITableViewCell"] autorelease];
}
// set search item information
WebSearchItem *wsi = [self.searchData objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[wsi title]];
[[cell detailTextLabel] setText:[NSString stringWithFormat:@"%@ - %@", [wsi descText], [[wsi releaseDate] dateToString:@"yyyy-MM-dd"]]];
[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
return cell;
}
Implementation of OverviewViewController.m init methods
- (id)init
{
[super initWithStyle:UITableViewStyleGrouped];
[[self navigationItem] setTitle:@"ReleaseDate"];
return self;
}
-(id)initWithStyle:(UITableViewStyle)style
{
return [self init];
}
UPDATE 2
OverviewViewController.h
@interface OverviewViewController : UITableViewController {
...
}
SearchViewController.h
@interface SearchViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UIActionSheetDelegate> {
IBOutlet UITableView *tableView;
...
}
@property (nonatomic, retain) IBOutlet UITableView *tableView;
The answer lies in the exception:
This says that some object (namely: a
UITableViewobject, allocated at memory address 0x502e000) was sent a message (“selector”, i.e. a method was called on it) which it doesn’t understand. The message is_saveOpaqueViewState:. Googling around you’ll find that this selector is normally called onUITableViewCellinstances.That would probably mean that you’re returning a
UITableViewsomewhere, where you should return aUITableViewCellinstead.Please have a look (or share) the code you have for
And see if the compiler doesn’t give some warnings there.
update Ok seeing your code we can conclude that this theory does not apply. The other option is that you prematurely release an object, so that the message sent to some
UITableViewCell(which has vanished) ends up at another object, incidentally aUITableView. You could try and setNSZombiesEnabled, or, as a first quick fix, put a line incellForRowAtIndexPath:likeThen you can compare the address logged there to the address from the stack trace, just as a start.
update2 yet another theory then: Do the two
UITableViewControllerobjects have their ownUITableViewobjects? I would imagine that having two controllers trying to work on one table view would lead to some inconsistencies.