I have loaded a new view using the code
UIViewController* newController = [[UIViewController alloc] initWithNibName:@"NFCController" bundle:nil];
[self.view addSubview:newController.view];
and this loads in the new view perfectly. However, I have connected a button in the new view to a class so that I can use the press event to do things. However, even though the method is still only:
- (IBAction)donePress:(id)sender {}
the app still crashes. I get the error EXC_BAD_ACCESS on the main method in main.m.
Has anyone got any ideas what could be causing this? I can provide more information on request.
Thanks.
Edit: This happens with all controls that are connected to methods.
your controller is getting released as it is not retained anywhere leading to crash. only your controller’s view is being retained.
Keeping your controller retained like with
Now your controller is also being retained. Your code will work fine now.