如何将String转换为PFObject

时间:2015-08-14 21:06:37

标签: ios string swift parse-platform pfobject

我已将解析后的列中的userIds保存为String,我希望将其转换为PFObject。我怎么能在swift中做到这一点?我试图按如下方式检索userIds:

followedUserQuery.findObjectsInBackgroundWithBlock { (objects, error) -> Void in

            if let objects = objects {

                for object in objects {

                    var followedUser = object["user"] as! PFObject

我收到此错误:

Could not cast value of type '__NSCFString' (0x105f94c50) to 'PFObject' (0x104708998).
谢谢你的时间。

1 个答案:

答案 0 :(得分:0)

试试这个

followedUserQuery.findObjectsInBackgroundWithBlock { (objects:[AnyObject], error:NSError) -> Void in
          if error == nil{
     if let objects = objects as! [PFObject] {
                for object in objects {
             var followedUser = object["user"] 
            }
}