Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-27-2009, 11:42 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 70
Default exec_bad_access when loading view second time

when I start my game from the main menu for the first time everything works fine. But after I go back to the menu and try to start the game again I get an exec_bad_access error that says something about dyld_stub_arc4random
the exec_bad_access is occuring in this method
Code:
-(void)menutonewgame{
    thegameViewController *gameview = [[thegameViewController alloc] initWithNibName:@"thegame" bundle:nil];
    [self setGameViewController:gameview];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:window cache:NO];
    [viewController.view removeFromSuperview];
    [self.window addSubview:[gameViewController view]]; //ERROR OCCURS HERE
    [UIView commitAnimations];
    [gameview release];
}
and the only place i use arc4random is inside thegameViewController in this 1 method
Code:
int getnext(){
	int i;
	do{
		i = arc4random() % 100;
	}while(level[i]==0 || level[i]==(int)NULL);
    int next = level[i];
    return next;
}
any help would be greatly appreciated. thanks.
firebug is offline   Reply With Quote
Old 12-28-2009, 06:29 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 792
Default

What is "viewController" ? Are you sure there is always a viewController.view properly set when you call the method ? If you call removeFromSuperview on an object that has been released, it'll crash.

Is "gameViewController" retained in your setGameViewController method ? It must be retained or you'll crash later, because you released the "gameview" variable. If it is a property, use the retain keyword next to its declaration. If you implemented it, manually retain the new value, release the old one, THEN assign it to your variable.
nobre84 is offline   Reply With Quote
Old 12-28-2009, 04:16 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 70
Default

Quote:
Originally Posted by nobre84 View Post
What is "viewController" ? Are you sure there is always a viewController.view properly set when you call the method ? If you call removeFromSuperview on an object that has been released, it'll crash.

Is "gameViewController" retained in your setGameViewController method ? It must be retained or you'll crash later, because you released the "gameview" variable. If it is a property, use the retain keyword next to its declaration. If you implemented it, manually retain the new value, release the old one, THEN assign it to your variable.
the viewController is just the menu screen which seems to be working fine, its the next line
[self.window addSubview:[gameViewController view]];
thats causing problems. gameViewController is just an instance of thegameViewController that i declared in the appdelegate and it is being retained in its property.
firebug is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 231
15 members and 216 guests
ADY, AragornSG, Dani77, Dattee, Duncan C, fkmtc, HDshot, HemiMG, Promo Dispenser, Punkjumper, Rudy, sacha1996, sneaky, spiderguy84, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:14 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0