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

Export Operation

In the first demonstration, we’ll add the ability to export recipes from Core Data so that they can be shared. We’ll create an NSOperation, which will create its own NSManagedObjectContext and use it to copy the selected recipes into a JSON structure, which can then be used by the application in several ways (uploaded to a server, emailed to a friend, and so on).

To implement this addition to our application, we need to make a few changes to the user interface. We want to add a button to the UINavigationBar that’s a generic action item. When the button is tapped, it will display an action sheet and give the user an option to mail the recipe (other options can be added later), as shown in the following figure.

To accomplish this, ...

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