我必须发表评论,试图在Parse中导入数组。但是,有一个问题。
当我尝试从Parse加载数组时,我的输出是(“Blah”,“Blah”,“Blah”) 这是一个元组....不是阵列TT .....
如何从Parse中正确引入数组?
这是我从解析
获取的fetch函数func fetchDataFromParse(){
var query = PFQuery(className:"Cafe")
query.whereKey("name", notEqualTo: "")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// The find succeeded.
// Do something with the found objects
if let objects = objects as? [PFObject] {
for object in objects {
self.imageText.append(object.objectForKey("name")! as! String)
self.commentArray = (object.objectForKey("comment")!) // This is array of comment from Parse!!
self.imageFiles.append(object.objectForKey("imageFile") as! PFFile)
self.messageTableView.reloadData()
}
}
} else {
// Log details of the failure
println("Error: \(error!) \(error!.userInfo!)")
}
}
}
答案 0 :(得分:0)
您可能需要使用以下命令将其强制转换为Swift数组:
self.commentArray = object.objectForKey(“comment”)为? [AnyObject]