Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.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
Ios 我希望Int变量的值等于不同类型数组(Swift)中的项数_Ios_Arrays_Swift_Swift3 - Fatal编程技术网

Ios 我希望Int变量的值等于不同类型数组(Swift)中的项数

Ios 我希望Int变量的值等于不同类型数组(Swift)中的项数,ios,arrays,swift,swift3,Ios,Arrays,Swift,Swift3,我希望Int类型的var numberPlaces获得与filteredList相同的值 list = NearbyPlaces.getCategories() filteredList = list.filter { _ in arc4random() % 2 == 0 } 但是filteredList属于QCategoryy类型,我该怎么办?因为我希望numberPlacesInt值与filteredList中的项目数相等 更新 numberPlaces在我的下一个viewCon

我希望
Int
类型的
var numberPlaces
获得与filteredList相同的值

list = NearbyPlaces.getCategories()

filteredList = list.filter { _ in
    arc4random() % 2 == 0
}
但是
filteredList
属于
QCategoryy
类型,我该怎么办?因为我希望
numberPlaces
Int值与
filteredList
中的项目数相等

更新

numberPlaces
在我的下一个viewController中

var numberPlaces = 0
在我的prepare函数的前一个控制器中

 if let np = segue.destination as? CourseClass2 {


            np.categories = filteredList
            np.numberPlaces = //here the number of items of filteredList
            np.radius = Int(stepperRadius.value)
        }

我敢打赌你的
过滤器列表
不是
QCategoryy类型的。它可能是
[QCategoryy]
类型,是
QCategoryy
对象的数组

您应该能够:

np.numberPlaces = filteredList.count

var numberPlaces在哪里?请出示所有相关代码我更新了问题