Reputation: 21
I'm doing something really simple. Trying to pushViewController. It works great on iPhone but on iPad, it crashes! SIGABRT:
libsystem_kernel.dylib`__pthread_kill:
0x35d85324: mov r12, #328
0x35d85328: svc #128
0x35d8532c: blo 0x35d85344 ; __pthread_kill + 32
0x35d85330: ldr r12, [pc, #4] ; __pthread_kill + 24
0x35d85334: ldr r12, [pc, r12]
0x35d85338: b 0x35d85340 ; __pthread_kill + 28
0x35d8533c: stmibeqr4, {r5, r6, r7, r10, r11}
0x35d85340: bx r12
0x35d85344: bx lr
Any thoughts? Thank you!
Principal *cvc;
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPhone"] || [deviceType isEqualToString:@"iPod touch"]) {
cvc = [[Principal alloc] initWithNibName:@"Principal" bundle:nil];
} else {
cvc = [[Principal alloc] initWithNibName:@"Principal_iPad" bundle:nil];
}
[cvc setImg:flippedImage];
if([deviceType isEqualToString:@"iPhone"] || [deviceType isEqualToString:@"iPod touch"]) {
[self.navigationController pushViewController:cvc animated:YES];
} else {
[self.navigationController pushViewController:cvc animated:YES];
}
[cvc release];
Upvotes: 0
Views: 541
Reputation: 7644
There might be something wrong with your xib like some connections that can not exist(which usually come along when you copy xib elements and forget to remove the selectors, etc). You can find your stack trace by adding the following code to your appDelegate:
void uncaughtExceptionHandler(NSException *exception) {
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
// Internal error reporting
}
The above method should be the first one in your appDelegate.m
Then, add NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
as the first line in your application:didFinishLaunchingWithOptions:
method as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);//should be the first line
....
....
}
Upvotes: 0
Reputation: 459
To get Actual Exception You have to set NSZombieEnabled
. To set NSZombieEnabled
goto Product->Edit Scheme->Arguments In Arguments you will find 'Environment Variables' here just Click on +
sign and add NSZombieEnabled
and check the checkbox beside that. Then you can see the exception. I thought the problem may not be with NavigationController. It may be in the PricipalViewController , Just check it by putting breakPoints at ViewDidLoad
in PrincipalViewController.
Upvotes: 0
Reputation: 5438
I think it is much easier to check for the UI Interface Idiom:
Principal *cvc;
if(UI_USER_INTERFACE_IDIOM() = UIUserInterfaceIdiomPhone) {
cvc = [[Principal alloc] initWithNibName:@"Principal" bundle:nil];
} else {
cvc = [[Principal alloc] initWithNibName:@"Principal_iPad" bundle:nil];
}
[cvc setImg:flippedImage];
[self.navigationController pushViewController:cvc animated:YES];
[cvc release];
Additionally you are doing the same thing in both cases of the last if
statement, so you can just remove it as I have done on the code.
In order to help you more, I need to see the actual exception text thrown before the crash.
I can imagine the problem is that self.navigationController
is defined on the iPhone but not on the iPad, or that the initialiser used for iPad is returning a nil
VC, and pushing a nil
view controller will throw an exception.
Upvotes: 2
Reputation: 5242
There is someting wrong with this;
Principal *cvc;
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPhone"] || [deviceType isEqualToString:@"iPod touch"]) {
cvc = [[Principal alloc] initWithNibName:@"Principal" bundle:nil];
} else {
cvc = [[Principal alloc] initWithNibName:@"Principal_iPad" bundle:nil];
// This should be allocated with the class Principal_iPad not Principal.
}
It should be something like this,
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPhone"] || [deviceType isEqualToString:@"iPod touch"]) {
Principal *cvc = [[Principal alloc] initWithNibName:@"Principal" bundle:nil];
[cvc setImg:flippedImage];
[self.navigationController pushViewController:cvc animated:YES];
[cvc release]
} else {
Principal_iPad *cvc = [[Principal_iPad alloc] initWithNibName:@"Principal_iPad" bundle:nil];
[cvc setImg:flippedImage];
[self.navigationController pushViewController:cvc animated:YES];
[cvc release]
}
Upvotes: 1