O'Reilly logo

Core Data in Swift by Marcus S. Zarra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Import Operation

The reverse of exporting recipes is to be able to import them. The experience we’re looking for is as follows:

  1. The user receives a recipe in another application (for example, in Mail).
  2. The user taps the recipe, and it opens in our application.
  3. Our recipe application receives the data and consumes it.

To accomplish this workflow, we need to step into our UIApplicationDelegate and do a few updates.

 func​ application(_ application: ​UIApplication​, open url: ​URL​,
  sourceApplication: ​String​?, annotation: ​Any​) -> ​Bool​ {
 guard​ ​let​ controller = dataController ​else​ {
  fileToOpenURL = url
 return​ ​true
  }
 if​ controller.persistenceInitialized {
  consumeIncomingFileURL(url) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required