I have an appdelegate(.h,.m) and two view controllers - loginviewcontroller, searchviewcontroller
On loginviewcontroller I have userid and password fields and login button. once login is verified searchviewcontroller view will be shown.
I have loginsuccess function defined in appdelegate and it is being called from loginviewcontroller.
AppDelegate
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
loginviewcontroller *aViewController = [[loginviewcontroller alloc] initWithNibName:@"loginviewcontroller" bundle:[NSBundle mainBundle]]; self.loginviewcontroller=aViewController; [aViewController release];
UIView *controllersView = [loginviewcontroller view]; [window addSubview:controllersView]; [window makeKeyAndVisible];
return YES; }
(void)loginSuccess {
[[loginviewcontroller view] removeFromSuperview];
SearchFormViewController *sformcontroller = [[SearchFormViewController alloc] initWithNibName:@"SearchFormViewController" bundle:[NSBundle mainBundle]]; self.searchformcontroller = sformcontroller; [sformcontroller release]; // UIView *searchfcontrol = [searchformcontroller view];
[window addSubview:[searchformcontroller view]];
}
loginviewcontroller.h
@interface loginviewcontroller : UIViewController {
loginappDelegate *appDelegate;
} @property (nonatomic, retain) IBOutlet DiamondbyHKAppDelegate *appDelegate;
loginviewcontroller.m appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate loginSuccess];
But it is not loading the second view(searchviewcontroller). instead the app crashes and comes out. can someone please point out the mistake?