App Crashes Loading View Controllers

Posted by golfromeo on Stack Overflow See other posts from Stack Overflow or by golfromeo
Published on 2010-06-13T01:37:39Z Indexed on 2010/06/13 1:42 UTC
Read the original article Hit count: 232

Filed under:
|
|

I have the following code in my AppDelegate.h file:

@class mainViewController;
@class AboutViewController;
@interface iSearchAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
mainViewController *viewController;
AboutViewController *aboutController;
UINavigationController *nav;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet mainViewController *viewController;
@property (nonatomic, retain) IBOutlet AboutViewController *aboutController;
@property (nonatomic, retain) IBOutlet UINavigationController *nav;
[...IBActions declared here...]
@end

Then, in my .m file:

@implementation iSearchAppDelegate

@synthesize window; @synthesize viewController, aboutController, settingsData, nav, engines;

(void)applicationDidFinishLaunching:(UIApplication *)application {

[window addSubview:nav.view];
[window addSubview:aboutController.view];
[window addSubview:viewController.view];

[window makeKeyAndVisible];

}

-(IBAction)switchToHome{ [window bringSubviewToFront:viewController.view]; } -(IBAction)switchToSettings{
[window bringSubviewToFront:nav.view];
}
-(IBAction)switchToAbout{
[window bringSubviewToFront:aboutController.view];
}

- (void)dealloc {
[viewController release];
[aboutController release];
[nav release];
[window release];
[super dealloc];
}

@end

Somehow, when I run the app, the main view presents itself fine... however, when I try to execute the actions to switch views, the app crashes with an EXC_BAD_ACCESS.

Thanks for any help in advance.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c