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
class Coordinator: UINavigationController { | |
init() { | |
super.init(nibName: nil, bundle: nil) | |
let firstVC = HostingController { FirstView(push: push) } | |
setViewControllers([firstVC], animated: false) | |
} | |
required init?(coder aDecoder: NSCoder) { |
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
struct ContentView: View { | |
@State var titles = ["Cell #1", "Cell #2", "Cell #3", "Cell #4"] | |
var body: some View { | |
NavigationView { | |
ScrollView { | |
VStack(spacing: 0) { | |
ForEach(self.titles, id: \.self) { title in | |
HStack { | |
Text(title) |
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
enum Page: Identifiable, CaseIterable { | |
case first, second | |
var title: String { | |
switch self { | |
case .first: | |
return "First" | |
case .second: | |
return "Second" | |
} |
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 SwiftUI | |
import CoreData | |
class CoreDataViewModel: NSObject, ObservableObject, NSFetchedResultsControllerDelegate { | |
let container: NSPersistentContainer | |
private var controllerUpdates = [NSObject: CurrentValueSubject<[NSFetchRequestResult], Never>]() | |
init(container: NSPersistentContainer) { | |
self.container = container |
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
// MARK: - Data Structures | |
enum Operation: String { | |
case add = "+" | |
case subtract = "-" | |
case multiply = "*" | |
case divide = "/" | |
var action: (Int, Int) -> Int { | |
switch self { |