Skip to content

Instantly share code, notes, and snippets.

@nicol3a
Last active February 8, 2019 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicol3a/06beea214e543140ac8e6f75b64687ee to your computer and use it in GitHub Desktop.
Save nicol3a/06beea214e543140ac8e6f75b64687ee to your computer and use it in GitHub Desktop.
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