然后我尝试将一个密钥从PFObject转换为一个String,它给了我一个错误。我在Parses网站上找不到任何东西。请帮忙
var findProgram = PFQuery(className: "Programs")
findProgram.getObjectInBackgroundWithId(data["program"] as! String!, block: { (object: PFObject?, error) -> Void in
if error == nil {
var objects = object["name"] as! String
print(objects)
self.programUpdated.append(object?.createdAt as NSDate!)
}
})
答案 0 :(得分:0)
我认为这是你必须要做的,试试这个:
//explicitly giving the objects var a type of String
var objects:String = object["name"] as! String
之后你不应该收到错误。
祝你好运!答案 1 :(得分:0)
我认为这将是最好的方法:
if let objects = object?.objectForKey("name") as? String{
print(objects)
self.programUpdated.append(objects?.createdAt as NSDate!)
}