Im trying to use the NSLog, to print console messages. The problem is sometimes i receive a "EXC_BAD_ACCESS" error when calling it
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
NSLog(@"Working test %d", toInterfaceOrientation);
NSLog(@"EXC_BAD_ACCESS %@", toInterfaceOrientation);
}
Here i simply want to see what the arguments passed into the function contain. The first NSLog works fine. The second causes an "EXC_BAD_ACCESS" and i dont understand why?.
%@
only works with objects. And toInterfaceOrientation is not an object.
As you can see in the documentation for UIInterfaceOrientation
it's just an enum.
The second NSLog crash because you try to print an integer as a NSObject (%@ instead of %d). UIInterfaceOrientation is a enum it doesn't work.
EXC_BAD_ACCESS usually means you're trying to call an object that's been released from memory. Try turning on NSZombies in your environment variables to see where it's causing the problem
Answer in a similar question here: How to use NSzombie in xcode?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With