如何从解析iOS获取对象ID

时间:2019-01-22 15:43:55

标签: swift parse-platform

代码

let number=UserDefaults.standard.object(forKey: "phone")
let s=PFQuery(className: "Customer")
s.whereKey("phonenumber", equalTo:number!)
s.getFirstObjectInBackground(block: { (gameScore: PFObject?, error: Error?) in
    if let error = error {
        //The query returned an error
        print(error.localizedDescription)
    } else {
        //The object has been retrieved
        print(gameScore?.objectId)
    }
})

我需要连续获取与电话号码匹配的对象ID,该怎么办?

1 个答案:

答案 0 :(得分:0)

我在调用查询时出错,查询只需要Int即可发送任何数据类型

 let number=UserDefaults.standard.object(forKey: "phone") as? String
   let Stringtonumber=Int(number!)
let s=PFQuery(className: "Customer")
s.whereKey("phonenumber", equalTo:Stringtonumber)
s.getFirstObjectInBackground(block: { (gameScore: PFObject?, error: Error?) in
    if let error = error {
        //The query returned an error
        print(error.localizedDescription)
    } else {
        //The object has been retrieved
        print(gameScore?.objectId)
    }
})