Reputation: 701
This is really basic. But I have no idea where I am going wrong.
I am on the ARC mode and all I have done is written the following code in my AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions function
homePage *hp = [[homePage alloc] init];
UINavigationController *navcon = [[UINavigationController alloc] initWithRootViewController:hp];
The home page gets loaded up correctly and there is a button on the homePage which when clicked should trigger a pressedPlay: wired up correctly in the .xib. But as soon as the button is clicked the program crashes with the error: EXC_BAD_ACCESS. Any help please?
Upvotes: 0
Views: 170
Reputation: 701
I found a fix to the problem. With ARC the view to be pushed into the navigation controller must have a strong property associated with it, otherwise it is released.
Upvotes: 0
Reputation: 39988
Try this
homePage *hp = [[homePage alloc] initWithNibName:@"homePage" bundle:nil];
UINavigationController *navcon = [[UINavigationController alloc] initWithRootViewController:hp];
And follow naming conventions instead of homePage
it should be HomePage
.
Upvotes: 0
Reputation: 14427
This usually means something had a reference count of zero and then you tried to use it.
I bet it is something to do with whatever your button touch event is trying to process. Step through the code and see exactly at what point the crash happens.
Upvotes: 1