iOS与Parse。 PFUser.currentuser()没有被缓存。应用程序重启后返回nil [英] iOS with Parse. PFUser.currentuser() not getting cached. Returns nil after app restart

查看:125
本文介绍了iOS与Parse。 PFUser.currentuser()没有被缓存。应用程序重启后返回nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Swarse构建一个应用程序。应用程序停止并再次运行后,PFUser.currentuser()始终返回nil。我正在使用iOS模拟器并启用了本地数据存储。
我使用的是这样的东西 -

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
}

登录时我正在使用

PFUser.loginWithUsernameInBackground(...)

当前用户保持不变,直到应用程序重新启动,之后它将重置为nil。我甚至试图固定当前用户,但它不起作用。
如何检查当前用户是否在本地缓存。
任何帮助将不胜感激。谢谢。

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.

推荐答案

对我来说,原因很简单,以下部分未执行。小心多线程。通常这就是原因。

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")

这篇关于iOS与Parse。 PFUser.currentuser()没有被缓存。应用程序重启后返回nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆