how can I know current viewcontroller name in iphone
Posted
by Shikhar
on Stack Overflow
See other posts from Stack Overflow
or by Shikhar
Published on 2010-04-14T07:05:26Z
Indexed on
2010/04/14
7:23 UTC
Read the original article
Hit count: 275
iphone
I have BaseView which implement UIViewController. Every view in project must implement this BaseView.
In BaseView, I have method:
-(void) checkLoginStatus { defaults = [[NSUserDefaults alloc] init];
if(![[defaults objectForKey:@"USERID"] length] > 0 )
{
Login *login=[[Login alloc] initWithNibName:@"Login" bundle:nil];
[self.navigationController pushViewController:login animated:TRUE];
[login release];
}
[defaults release];
}
The problem is my Login view also implement BaseView, checks for login, and again open LoginView i.e. stuck in to recursive calling.
Can I check in checkLoginStatus method if request is from LoginView then take no action else check login. Ex:
(void) checkLoginStatus { if(SubView is NOT Login){ defaults = [[NSUserDefaults alloc] init];
if(![[defaults objectForKey:@"USERID"] length] > 0 ) { Login *login=[[Login alloc] initWithNibName:@"Login" bundle:nil]; [self.navigationController pushViewController:login animated:TRUE]; [login release]; } [defaults release]; } }
Please help..
© Stack Overflow or respective owner