What I want to do is to, after storing several objects of type CodigosAutorizacion inside an array:
for value in 0..<(array.count) {
let codeArray = CodigosAutorizacion(
code: validateData!["codigo"] as? String,
codeCancel: validateData!["cancela_codigo"] as? String,
codeSite: validateData!["cod_sitio"] as? String,
codeSiteCancel: validateData!["cancela_cod_sitio"] as? String,
instance: validateData!["instancia"] as? String
)
codes.append(codeArray)
}
Access the object attributes from the array like this:
codeCell.codigoSitio.text = codes[indexPath.row].instance
This piece throws me the next errors
-No exact matches in call to subscript
-Reference to member ‘instancia’ cannot be resolved without a contextual type
this is because ´codes´ is an array and not a CodigosAutorizacion type
Storing these objects in an array is important because I will need to generate a table with several of this CodigosAutorizacion objects. Is there any way this can be possible?
2
Answers
Fixed! it was a problem with the
codes
array declaration, it was not supposed to bevar codes: Array<Any>
but insteadvar codes: Array<CodigosAutorizacion>
in order to access CodigosAutorizacion's properties— Try this —