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 AppDelegate: UIResponder, UIApplicationDelegate { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
// Initialize store | |
let context: NSManagedObjectContext = ... | |
let store = EventStore(context: context) | |
// Initialize root view controller | |
let viewController = EventListTableViewController(store: store) | |
// Initialize window... | |
} | |
} | |
class AddEventViewController: UIViewController { | |
private let store: EventStore | |
init(store: EventStore) { | |
self.store = store | |
super.init(nibName: nil, bundle: nil) | |
} | |
func addEventButtonTapped() { | |
let event = Event() | |
event.title = "I went to the hairdresser" | |
event.date = Date() | |
store.insert(event) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment