2
Good afternoon, you guys. I’m having a hard time uploading the content of a Pickerview in my app, as it needs to fetch the information in a call GET
, the call works and I can assemble the array
with the content I need, but I can’t get the function that builds the array
return it for me to click on Pickerview. I build a array
of categories and, from it, extract only the information "description" of each category that exists in the array
, to click on Pickerview. Below is the part of my code I’m having problems with:
var categoriaArray = Array<Categoria>()
for obj:AnyObject in post {
let dict = obj as! NSDictionary
let categoria = Categoria()
categoria.descricao = dict["descricao"] as! String
categoria.id = dict["id"] as! Int
categoria.valorCasadinha = dict["valorCasadinha"] as! Double
categoria.valorTerceira = dict["valorTerceira"] as! Double
categoriaArray.append(categoria)
}
var descricoes = Array<String>()
for categoria in categoriaArray{
descricoes.append(categoria.descricao)
}
print("Descrições: \(descricoes)")
print("Quantidade de Categorias: \(categoriaArray.count)")
})
task.resume()
I can print the contents of array
that need (descriptions), but need to be returned in the function that builds it, ie, need a return descricoes
after the task.resume()
. I hope you can help me. Thanks in advance.
Do you have a way to add more code? In general if your array has the values you expect then, technically, all you would need to do is give
reload
in Picker and make it take the new array values.– Otávio