You have already created a managed object, and you want to instantiate it and insert that instance into your app’s Core Data context.
Follow the instructions in Recipe 18.1 and Recipe 18.2. Now you can
class method of
to create a new object of a type specified by the first parameter of
this method. Once the new entity (the managed object) is created, you
can modify it by changing its properties. After you are done, save your
managed object context using the
save: instance method of the managed object
I’ll assume that you have created a universal application in Xcode with the name Creating and Saving Data Using Core Data; now, follow these steps to insert a new managed object into the context:
Find the implementation file of your app delegate.
Import the Person.h file into the app delegate’s implementation file:
Person is the entity we
created in Recipe 18.1.
method of your shared application delegate, write this code: