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 :-)
你還沒有說過什麼是不工作的。它只是返回零嗎?你確定這不正確? – 2015-02-11 16:23:30
它返回零(見下文) – dgee4 2015-02-11 16:42:55