使用闭合
由于某种原因,在模拟器上测试我的应用程序时,用户数据永远不会更新。例如,对象"年龄"的值可以更改为22,但是模拟器的行为仿佛仍然是21岁。有人会知道这只是模拟器问题,并且在电话上会有所不同吗?我的iPhone的屏幕已完全损坏,因此我现在无法测试。
在解析中,pfuser是PfObject的子类,用于更新Parse iOS SDK中的PfObject,您有很多方法可以做到这一点
有两种流行方法:
- 提取以同步更新对象
- 获取background以异步更新对象
例如,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