handling the logout functionality on the iPhone
This is the first iPhone application i am working on.
To use the application, the user has to login to our server. I am done with that part.
Now the problem i am facing is how to logout the user from the server, deallocate all the memory and start afresh without quitting the app. After the user logs out, i want the exact same 开发者_运维技巧things to happen as in applicationdidfinishlaunching method. But i dont know how to go about it.
The app has a tab bar which is set up in mainWindow.xib.
Create an object that contains all the data that your user will use/require. Add this object as a property of the App delegate.
MyUser *myUser;
...
@property (nonatomic, retain) MyUser *myUser;
Then launch the application as normal and on pages that require the person logged in, check to see if there is a valid user in the delegate. If not, launch a login screen.
if (!delegate.myUser) {
LoginPageViewController *loginController = [[LoginPageViewController alloc] initWithNibName:@"LoginPage" bundle:nil];
[self presentModalViewController:loginController animated:YES];
This will cause the login page to appear. If the user successfully logs in, set the property in the delegate.
To log the person out, set the property to nil. This will force them to log in again when they want to access the restricted pages
精彩评论