I would like to know how I could receive a Dictionary and Convert it into an Array of type Classes. I receive the dictionary in Json and download it with alamofire. What I would need help with is creating the function that converts me to a vector.
import UIKit
enum DiasClases {
case Lunes
case Martes
case Miercoles
case Jueves
case Viernes
case Sabado
static func allValues() -> [DiasClases] {
return [Lunes, Martes, Miercoles, Jueves, Viernes, Sabado]
}
}
struct Clases {
let id: Int
let dia: DiasClases
let horario: String
let materia: String
let profesor: String
let seccion: String
}
func fromDictionary( dictionary: NSDictionary) -> [DiasClases]
{
var Clases = [DiasClases]()
let list = dictionary["Horario"] as? NSArray
for (IndexSet, value) in Clases.enumerated() {
Clases.append(Clases)
}
}
Assuming your JSON is similar to this: