序言
我使用 Parse.com 作为后端。
我已经建立了注册和身份验证功能来证实 PFUser。
我已经建立了一个注销按钮来将 PFUser 值重置为 0(零)。
这些功能存在于独立于应用程序核心的有形 View Controller 上。
问题
我想创造一种用户体验,其中:
如果在 PFUser 得到证实后终止申请:
下次打开应用程序时:
PFUser 应该被恢复并定向到应用程序核心中的特定 View Controller 。而不必重新登录。
额外
我怀疑以下代码适用:
[来源:PARSE IOS DOCUMENTATION: CURRENT USER ]
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
// show application nucleus view controller
} else {
// show the signup / login view controller
}
结合以下内容:
[ 来源:默认 IOS 应用程序代表 ]
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
和
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
}
外传
非常感谢任何指向解决方案的指针。预先感谢您的帮助。
最佳答案
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UIViewController *NewViewController = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
UIViewController *LoginViewController = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
if([PFUser currentUser])
{
[self.window setRootViewController:NewViewController];
}
else
{
[self.window setRootViewController:LoginViewController];
}
return YES;
}
关于ios - 在应用程序终止后保留 PFUser 当前用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24947509/