2015-02-11 52 views
0

我正在使用Xcode,直到今天还没有意识到任何问题。我的AppDelegate使用以下代码来确定用户应该被定向到主窗口还是登录屏幕。解析[PFUser currentUser]不工作

// determine the initial view controller here and instantiate it 
    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 

    PFUser *currentUser = [PFUser currentUser]; 

    UIViewController *viewController = [[UIViewController alloc] init]; 
    if (!currentUser) { 
     // Show Login/Sign Up Window 
     viewController = [storyboard instantiateViewControllerWithIdentifier:@"signUpOrRegister"]; 
    } else { 
     // User Logged In Already 
     viewController = [storyboard instantiateViewControllerWithIdentifier:@"rootVC"]; 
    } 

    self.window.rootViewController = viewController; 
    [self.window makeKeyAndVisible]; 

然后下面的代码登录。登录已在日志中注册。

[PFUser logInWithUsernameInBackground:[_loginUsernameField.text lowercaseString] 
           password:_loginPasswordField.text 
            block:^(PFUser *user, NSError *error) { 
             if (user) { 
              // Do stuff after successful login. 
              [self displayMessageToUser:@"Welcome Back"]; 
              NSLog(@"Successful: Login: %@", user.objectId); 
              [self segueToWindowOfChoice]; 
             } else { 
              // The login failed. Check error to see why. 
... 

任何想法?

感谢

d :-)

+3

你还没有说过什么是不工作的。它只是返回零吗?你确定这不正确? – 2015-02-11 16:23:30

+0

它返回零(见下文) – dgee4 2015-02-11 16:42:55

回答

0

我刚才通过更新解析框架已经解决了奇怪的问题解决了吗?在未来的这种情况下可能对人有用