0

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.

So, I think it has something to do with memory management, but I'm not quite sure.

Thanks for any help in advance.

Link to screenshots of code is here: link...

SOLVED: I fixed the issue by taking out the IBActions and making them into regular methods... apparently, XCode doesn't like it when you put IBActions in an AppDelegate.

element119
  • 7,475
  • 8
  • 51
  • 74

2 Answers2

0

Somewhere in your code, you are invoking [iSearchAppDelegate performSelector:withObject:withObject:]. You haven't shown that code here but that's likely where the problem is.

Matt Gallagher
  • 14,858
  • 2
  • 41
  • 43
  • Is it possible that that method is invoked by another method? Because I definitely never typed a "performSelector" method... – element119 Jun 13 '10 at 06:08
0

... message sent to deallocated instance ...

If it is memory management, my first step would be to enable NSZombie and discover what was being messaged after being dealloc'ed. Two obvious things I can think of:

  1. Uninitialised property/variable.
  2. De-allocated (non-retained) property

Have your controls in interface builder been connected to the IBActions?

Community
  • 1
  • 1
ohhorob
  • 11,695
  • 7
  • 41
  • 50
  • Thanks- I fixed the problem- apparently, it was the IBActions that was causing the app to crash, I guess you can't have IBActions with an App Delegate. – element119 Jun 13 '10 at 20:26