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.

 -​ (BOOL)application:(UIApplication *)application
  openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
 if​ ([[self dataController] isPersistenceInitialized]) {
  [self consumeIncomingFileURL:url];
  } ​else​ {
  [self setFileToOpenURL:url];
  } ...

Get Core Data in Objective-C, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.