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在哪里?请出示所有相关代码我更新了问题