Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

EXC_BAD_ACCESS Error

Hey Guys,


This is my first app/objective-c experiment, so bare with me...


I'm trying to start small. All I have so far is the app loading, serving up a view with a button. When the user clicks that button they are taken to view two, which has a "back" button, that is intended to do the reverse. The first button animates in the second view perfect, but the "back" button crashes the app and serves up the "EXC_BAD_ACCESS" error.


Here is the code:


From the SetupViewController button:

- (IBAction)BtnRequestSetup:(id)sender {

RequestSetupView *page = [[RequestSetupViewalloc] initWithNibName:@"RequestSetupView"bundle:nil];

CGRect theFrame = page.view.frame;

theFrame.origin = CGPointMake(self.view.frame.size.width, 0);

page.view.frame = theFrame;

theFrame.origin = CGPointMake(0,0);

[UIViewbeginAnimations:nilcontext:nil];

[UIViewsetAnimationDuration:0.8f];

page.view.frame = theFrame;

[UIViewcommitAnimations];

[self.view addSubview:page.view];

[page release];

}


From the RequestSetupView "back" button (this is what throws the error - when I click the button)

- (IBAction)BtnBacktoSetup:(id)sender {

SetupViewController *page2 = [[SetupViewControlleralloc] initWithNibName:@"SetupViewController"bundle:nil];

CGRect theFrame2 = page2.view.frame;

theFrame2.origin = CGPointMake(self.view.frame.size.width, 0);

page2.view.frame = theFrame2;

theFrame2.origin = CGPointMake(0,0);

[UIViewbeginAnimations:nilcontext:nil];

[UIViewsetAnimationDuration:0.8f];

page2.view.frame = theFrame2;

[UIViewcommitAnimations];

[self.view addSubview:page2.view];


}


Let me know if you need more to clarify. Thanks in advance.

Posted on Dec 13, 2011 8:10 PM

Reply
1 reply

Jul 15, 2013 8:20 PM in response to EvolveCreativeGroup

after init this class in method:

SetupViewController *page2 = [[SetupViewControlleralloc]initWithNibName:@"SetupViewController"bundle:nil];


it load a long time, after completed all command methods, ARC killed a page2 , and page from a memory. After loaded page instanse a class it start loadView but object SetupViewController or RequestSetupView not exist more in memory. It's call error EXC_BAD_ACCESS.


For solve it trouble, just define variable not in methods, but define it in instance scope.

EXC_BAD_ACCESS Error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.