0
I have a webapi that returns a list of evidence:
{
"Provas": [
{
"Codigo": "11111111111",
"Disciplina": {
"Codigo": "111111",
"Nome": "SOCIOLOGIA E EDUCAÇÃO"
},
"Tipo": "SUB",
"Correcao": "2016-07-01T14:33:33.383",
"Exame": false,
"Sub": true
},
{
"Codigo": "22222222222",
"Disciplina": {
"Codigo": "333333",
"Nome": "EDUCAÇÃO DE JOVENS E ADULTOS: FUNDAMENTOS E METODOLOGIA"
},
"Tipo": "SUB",
"Correcao": "2016-06-30T11:53:11.207",
"Exame": false,
"Sub": true
},
{
"Codigo": "333333333333",
"Disciplina": {
"Codigo": "444444",
"Nome": "METODOLOGIA E PRÃTICA DO ENSINO DA HISTÓRIA E GEOGRAFIA"
},
"Tipo": "BIMESTRAL",
"Correcao": "2016-06-29T09:42:29.097",
"Exame": false,
"Sub": false
}
]
}
And I created a class called Proof
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 call Discipline
import Foundation
class Disciplina
{
let codigo:String
let nomedisciplina:String
init(codigo:String, nomedisciplina:String)
{
self.codigo = codigo
self.nomedisciplina = nomedisciplina
}
}
Would you like to know how to convert this data to a list of Proofs according to my class? , I need to change something in the construction of these classes?
Dude worked great thanks.
– Julio Figueiredo
But how would it look inside a Tableviewcontrollor?? , I created a function to call this data via Alamofire, I did all the table view code but do not click on the tableview
– Julio Figueiredo
As you already have the array of
Provas
just run it through the Tableviewcontroller in case you’re not on it and call thereloadData()
:– iTSangar
I was forgetting about the timeData(), now it worked out thanks!!!
– Julio Figueiredo
How do I save this Proof object in a session (Nsuserdefaults)
– Julio Figueiredo
I have a little different situation my json doesn’t have a title on top it already comes this way [{ "id": "1", "Description": "TEST 1", "live": "https://www.example1.com/live", "Thumb": "https://www.example1.com/thumb", "online": true }, {"id": "2", "Description": "TEST 2", "live": "https://www.exe2amplcom.live/", "Thumb": "https://www.example2.com/thumb", "online": true }]
– João Vitor