在cellForRowAtIndexPath函数中,我创建了这个,以便它会为每个帖子附加相似数量,但由于某种原因它会崩溃。有谁知道为什么?
var postQuery = PFQuery(className: "Post")
postQuery.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if let objects = objects {
for object in objects {
self.likesArray.append((object["likers"] as! [String]).count)
}
}
}
答案 0 :(得分:1)
您需要打开可选的....
var postQuery = PFQuery(className: "Post")
postQuery.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if (objects != nil) {
for object in objects! {
self.likesArray.append((object["likers"] as! [String]).count)
}
}
}
请尝试这个并告诉我它是否解决了您的问题