由于某种原因,在模拟器上测试我的应用程序时,用户数据从未更新。例如,对象“age”的值可以更改为 22,但模拟器的行为就好像它仍然是 21。有人知道这是否只是模拟器问题,并且在手机上运行会有所不同吗?我的 iPhone 屏幕完全坏了,所以我现在无法测试。
最佳答案
在解析中,PFUser是 PFObject 的子类,更新 PFObject在 Parse iOS SDK你有很多方法可以做到这一点
有两种流行的方法:
- fetch更新您的对象 synchronously
- fetchInBackground更新您的对象 asynchronously
例如 fetch :
guard let myUser = PFUser.current() else { return } // Get the current user
do {
try myUser.fetch()
} catch {
print("Error when fetching the new data")
}
例如 fetchInBackground :
guard let myUser = PFUser.current() else { return } // Get the current user
myUser.fetchInBackground()
您还可以使用 fetchInBackgroundWithBlock 来关闭
关于ios - 解析 PFUser 数据未在 iPhone 模拟器上更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43749480/