我有这个代码
func didFinishSaveCategorias(datos: [String]) {
filter = 1
// var found = 0 no longer needed break stament in for make the deal
print("datos de Parametros \(datos)")
categorias = datos
//jsonData[0]["categorias"].array?.contains(categorias)
//
for subJson in jsonData{
for i in 0..<categorias.count{
if categorias.contains(subJson["categorias"][i]["id"].stringValue){
filterData.append(subJson)
break
/*if found == 0{ // this could be like so delete this line
filterData.append(subJson) //keep this one
found = 1 //this one should be break this end the for i in ... and make the other for go on in subjson
}*/
}
}
//found = 0
}
myTableView.reloadData()
}
我尝试使用此
制作过滤器 filterData = jsonData.filter({$0["categorias"].arrayValue.contains(categorias)})
但xcode抱怨[string]不是指定的[json]类型 所以要解释json数组在每个元素中包含一个带有几个选项的categoria数组 我想避免2循环,如果if condiftion得到纠正意味着如果json的每个位置中的数组类别几乎有一个分类数组中的类别附加到新数组