This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class Datasource { | |
func pets() -> [Pet] { | |
[ | |
Pet(id: "1", name: "Max", ownerId: "1"), | |
Pet(id: "2", name: "Azor", ownerId: "1"), | |
Pet(id: "3", name: "Monty", ownerId: "2"), | |
Pet(id: "4", name: "Zizou", ownerId: "3"), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func addInt(_ a: Int, _ b: Int) throws -> Int { | |
let result = a.addingReportingOverflow(b) | |
if result.overflow { | |
throw AddError.overflow | |
} | |
return result.partialValue | |
} | |
enum AddError: Error { | |
case overflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@ObservedObject var viewModel: ContentVM | |
var body: some View { | |
NavigationView { | |
List(viewModel.values, id: \.self) { value in | |
Text(value) | |
}.navigationBarTitle("Our Cells") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Apostolos Giokas on 23.03.21. | |
// | |
final class MyViewControllerFactory: ViewCοntrollerFactory { | |
override init() { | |
super.init() | |
register(vm: Data1.self) { UIViewController1(data: $0) } | |
register(vm: Data2.self) { UIViewController2(data: $0) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Apostolos Giokas on 23.03.21. | |
// | |
import UIKit | |
class ViewController: UIViewController, IViewControllerNavigator { | |
let button1 = UIButton(frame: CGRect(x: 50, y: 100, width: 200, height: 45)) | |
let button2 = UIButton(frame: CGRect(x: 50, y: 200, width: 200, height: 45)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Apostolos Giokas on 23.03.21. | |
// | |
import UIKit | |
open class ViewCοntrollerFactory: Factory<UIViewController> { | |
public func register<T, OutP>(vm: T.Type, factory: @escaping (T) -> OutP) where OutP: UIViewController { | |
register(for: vm, factory: { factory($0) }) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Apostolos Giokas on 10.03.21. | |
// | |
import Foundation | |
private protocol ICreator { | |
var identifier: ObjectIdentifier { get } | |
func create(for: Any) -> Any? | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
import CoreData | |
import Foundation | |
class CDPublisher<Entity>: NSObject, NSFetchedResultsControllerDelegate, Publisher where Entity: NSManagedObject { | |
typealias Output = [Entity] | |
typealias Failure = Error | |
private let request: NSFetchRequest<Entity> | |
private let context: NSManagedObjectContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreData | |
import Foundation | |
import os.log | |
import RxCocoa | |
import RxSwift | |
class CDObservable<T>: NSObject, ObservableType, NSFetchedResultsControllerDelegate where T: NSManagedObject { | |
private var fetchedResultsController: NSFetchedResultsController<NSManagedObject>? | |
private let context: NSManagedObjectContext | |
private let fetchRequest: NSFetchRequest<T> |
NewerOlder