Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays swift如何将解析号列追加到数组中_Arrays_Xcode_Swift - Fatal编程技术网

Arrays swift如何将解析号列追加到数组中

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

我在parse中有一列存储数字。我一直在尝试将数字附加到如下数组:

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)}