I have created my app, I have all my data inside a object of a class, this is the class:
class ClaseContenedora {
var calendarios = [Calendario]()
var seleccionados = ValoresDeSeleccionados()
var valoresConfiguracion = OpcionesConfiguracion()
init(cal: [Calendario], selected: ValoresDeSeleccionados, config: OpcionesConfiguracion) {
self.calendarios = cal
self.seleccionados = selected
self.valoresConfiguracion = config
}
}
as you can see, I have and array of another class and 2 objects of other classes. These are the 2 last clases:
class ValoresDeSeleccionados {
var calendarioSeleccionado = 0
var seccionSeleccionada = 0
var asistenciaSeleccionada = 0
var actividadSeleccionada = 0
var alumnoSeleccionado = 0
}
and:
class OpcionesConfiguracion {
var setColores = true // -> Colores de Interfaz (TRUE = GRISES, FALSE = COLORES PASTEL)
var defaultCalificacion = 100 // -> Default al agregar una nueva Actividad o dia de clases(asistencia)
var defaultAsistencia = true // ->
var defaultCalificacionNuevoAlumno = 100 // -> Default al agregar un alumno y que ya haya clases con asistencia o actividades realizadas
var defaultAsistenciaNuevoAlumno = true // ->
var ordenarAlumnosPorOrdenAlfabetico = false
var asistenciasPorDiaClaseUnDia = 2
var asistenciaPorDiaClaseVariosDias = 1
var minimoPorcentajeOrdinario = 80
var resaltarAlumnosOrdinario = false
}
how can I save all this data 'permanently' I mean, that I could close the app, and continue later with the data I have created in the app?
I have tried some of this: http://nshipster.com/nscoding/ But every tutorial I have seen uses Int, String, Bool, not arrays or objects.
EDIT: This is the Calendario class:
class Calendario { // CLASE PRINCIPAL QUE CONTIENE 'SECCIONES'.
var secciones = [Seccion]()
var nombre: String
var inicio: Date
var fin: Date
init?(nombre:String, inicio:Date, fin:Date) {
//GUARD ES IGUAL A UN IF QUE SE CUMPLE, SI NO, ESTA EL ELSE.
guard (!nombre.isEmpty) else {
return nil
}
self.nombre = nombre
self.inicio = inicio
self.fin = fin
}
}