Last active
February 8, 2019 23:16
-
-
Save nicol3a/06beea214e543140ac8e6f75b64687ee to your computer and use it in GitHub Desktop.
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