Sunday, January 15, 2012

EXC_BAD_ACCESS when opening modal view


I'm having a problem with my iPhone App, I'm getting EXC_BAD_ACCESS, I had some memory leaks, but these are now fixed, so I'm not sure whats going on. I realise that I haven't provide a lot of information, but I really don't know whats happening.



The initial screen opens up where I have a number of buttons. Tapping on the first button, which runs the following code and opens up a modal view:




-(IBAction)newWorkoutButton
{
newWorkoutViewController .loadedFromRootViewController = @"YES";
[self presentModalViewController:newWorkoutViewController animated:YES];
}



The screen freezes and the is in the code below:




#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import <CoreLocation/CoreLocation.h>


int main(int argc, char *argv[])
{
Method getDistanceFrom = class_getInstanceMethod([CLLocation class], @selector(getDistanceFrom:));
class_addMethod([CLLocation class], @selector(distanceFromLocation:), method_getImplementation(getDistanceFrom), method_getTypeEncoding(getDistanceFrom));

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); // ERROR HAPPENING HERE
[pool release];
return retVal;
}

No comments:

Post a Comment