Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//
// OperatingSystemStore.swift
// CombinedUIKit
//
// Created by Adolfo Vera Blasco on 17/06/2019.
// Copyright © 2019 desappstre.com. All rights reserved.
//
import SwiftUI
import Foundation
import Combine
public class OperatingSystemStore: BindableObject
{
// MARK: - BindableObject Protocol -
///
public var didChange = PassthroughSubject<Void, Never>()
// MARK: - Tipo anidado -
// Representa un sistema operativo
public struct OperatingSystem
{
public private(set) var name: String
public private(set) var version: String
public init(named name: String, version: String)
{
self.name = name
self.version = version
}
}
/// Los sistemas operativos. De momento se cargan dos
public private(set) var systems: [OperatingSystem]
/// Empezamos con las dos últimas versiones de **macOS**
public init()
{
self.systems = [
OperatingSystem(named: "Catalina", version: "10.15"),
OperatingSystem(named: "Mojave", version: "10.14")
]
}
///
public func add(_ system: OperatingSystem) -> Void
{
// Añadimos el nuevo sistema operativo
self.systems.append(system)
// Notificamos el cambio a la vista
self.didChange.send()
}
}
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.