I have a web api that returns a certain JSON
{
"Provas": [
{
"Codigo": "16505984073",
"Disciplina": {
"Codigo": "657060",
"Nome": "DISCIPLINA 1"
},
"Tipo": "SUB",
"Correcao": "2016-07-01T14:33:33.383",
},
{
"Codigo": "16994242303",
"Disciplina": {
"Codigo": "652640",
"Nome": "DISCIPLINA 2"
},
"Tipo": "SUB",
"Correcao": "2016-06-30T11:53:11.207",
},
{
"Codigo": "16916014662",
"Disciplina": {
"Codigo": "652540",
"Nome": "DISCIPLINA 3"
},
"Tipo": "BIMESTRAL",
"Correcao": "2016-06-29T09:42:29.097",
},
{
"Codigo": "16892010587",
"Disciplina": {
"Codigo": "656140",
"Nome": "DISCIPLINA 4"
},
"Tipo": "BIMESTRAL",
"Correcao": "2016-06-25T14:49:57.17",
},
{
"Codigo": "16435696693",
"Disciplina":
{
"Codigo": "611460",
"Nome": "DISCIPLINA 5"
},
"Tipo": "BIMESTRAL",
"Correcao": "2016-05-04T15:42:08.363",
}
]
}
I created a class named "Prova"
import Foundation
class Prova
{
let codigo:String
let tipo:String
let dtcorrecao:NSDate
let disciplina:Disciplina
init(codigo:String, tipo:String, dtcorrecao:NSDate, disciplina:Disciplina)
{
self.codigo = codigo
self.tipo = tipo
self.dtcorrecao = dtcorrecao
self.disciplina = disciplina
}
}
and another name "Disciplina"
import Foundation
class Disciplina
{
let codigo:String
let nomedisciplina:String
init(codigo:String, nomedisciplina:String)
{
self.codigo = codigo
self.nomedisciplina = nomedisciplina
}
}
I would like to complete this return wepapi instancing my object "Proof" and then populate a table without using "Alamofire" and "ObjectMapper," I wonder if there is something native '' Swift 3.0 ''. I do not know if this would be good practice to work with web data (return data in '' JSON '' and convert to object), if not they could show me what would be in code for '' Swift 3.0 '', I am the '' Xcode 8 '' already. I need to change or add something in my classes?