Arrays swift如何将解析号列追加到数组中
我在parse中有一列存储数字。我一直在尝试将数字附加到如下数组:Arrays swift如何将解析号列追加到数组中,arrays,xcode,swift,Arrays,Xcode,Swift,我在parse中有一列存储数字。我一直在尝试将数字附加到如下数组: var likes = [Int]() getPostsQuery.findObjectsInBackgroundWithBlock { (posts, error) -> Void in if let posts = posts { self.likes.removeAll(keepCapacity: true) for post in posts
var likes = [Int]()
getPostsQuery.findObjectsInBackgroundWithBlock { (posts, error) -> Void in
if let posts = posts {
self.likes.removeAll(keepCapacity: true)
for post in posts {
self.likes.append((post["likes"] as? Int)!)
}
}
}
但它不起作用,我得到了这个错误
我一直在寻找添加数字的正确方法,但运气不好。我也尝试了NSNumber,但仍然不起作用。请帮忙,谢谢 错误信息是什么?你确定post[“likes”]中有值吗?尝试更改-self.likes.append((post[“likes”]as?Int)!-如果让value=post[“likes”]as?Int{self.likes.append(values)}