iOS with Parse. PFUser.currentuser() not getting cached. Returns nil after app restart

倖福魔咒の 提交于 2019-12-21 04:00:16

问题


I am building an app with Parse in swift. PFUser.currentuser() always returns nil after the app is stopped and run again. I am using the iOS simulator and the local datastore is enabled. I am using something like this -

if PFUser.currentuser() == nil {
// Perform segue to login screen
}

And for login I am using

PFUser.loginWithUsernameInBackground(...)

The currentuser remains till the app is restarted, after which it is reset to nil. I have even tried to pin the currentuser but it doesn't work. How can I check if the currentuser is being cached locally. Any help would be appreciated. Thanks.


回答1:


For me, the reason is simply the following part is not executed. Be careful of multi-thread. Usually that's the cause.

Parse.setApplicationId("xx","xx")



回答2:


Are you sure you're not resetting the simulator and are running on the same one? It should not clear the currentUser. Is it possible you are calling

PFUser.logout()

in 'applicationWillTerminate' in AppDelegate or anywhere else?



来源:https://stackoverflow.com/questions/31121867/ios-with-parse-pfuser-currentuser-not-getting-cached-returns-nil-after-app-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!