【问题标题】:Parse PFUser data not updated on iPhone Simulator解析 iPhone 模拟器上未更新的 PFUser 数据
【发布时间】:2017-05-03 01:06:32
【问题描述】:

由于某种原因,在模拟器上测试我的应用时,用户数据永远不会更新。例如,对象“age”的值可以更改为 22,但模拟器的行为就好像它仍然是 21。有人知道这是否只是模拟器问题,并且在手机上运行会有所不同吗?我的 iPhone 屏幕完全坏了,所以我现在无法测试。

【问题讨论】:

  • 我在真实设备上遇到了同样的问题。
  • @GellertLee 那么你认为这是 Parse 问题吗?
  • @Dups 你是在手机上更新数据还是在服务器上更新数据?
  • @JulienKode 评论? Genre si c'est fait à travers le code ou manuellement?
  • guard let myUser = PFUser.currentUser() else { return } // Get the current user do{ let data = try myUser.objectForKey("chargeID")?.fetch() try chargeID = data! as! String }catch{}

标签: ios swift xcode parse-platform parse-server


【解决方案1】:

在 Parse 中,PFUserPFObject 的子类,要更新Parse iOS SDK 中的PFObject,您有很多方法可以做到这一点

有两种流行的方法:

例如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闭包

【讨论】:

    猜你喜欢
    • 2011-01-04
    • 1970-01-01
    • 2011-12-31
    • 2015-08-30
    • 2020-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    相关资源
    最近更新 更多