Skip to content

Instantly share code, notes, and snippets.

@fitomad fitomad/memento_database.swift Secret
Created Apr 23, 2019

Embed
What would you like to do?
public class Database: CareTaker
{
/// Este `Array` hace las veces de base de datos
private var items: [Memento]
/// Todos los *snapshots* disponibles
public var mementos: [Memento]
{
return items
}
/**
Creamos una base de datos vacía
*/
public init()
{
self.items = [Memento]()
}
/**
Guarda un *snapshot*
*/
public func saveMemento(_ memento: Memento) -> Void
{
self.items.append(memento)
}
/**
Recupera el último *snapshot*
*/
public func lastMemento() -> Memento?
{
return items.last
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.