ios - Objective c - Core Data saving approach -


i have nsmanagedobject subclass in app, , i'm trying understand when , how save changes.
try explain myself, example class a nsmanagedobject subclass.
during app life cycle do:

app launched ... create instance of class ... change properties of instance ... app go background ... app becomes active again ... change more properties of instance ... app terminates 

when need call [context save:] ??
call after every change in instance? or maybe call when app go background?
should call after creation or deletion of instance?

a nice approach place uimanageddocument in appdelegate. can call [context save] whenever change occurs in app (like crash). order follow like:

  1. create uimanageddocument object (in application did load or wherever) , assign property
  2. setup document (check whether exist on disk or open, etc.. , respond accordingly)
  3. pass uimanagedobjectcontext initial uiviewcontroller in app (from there can pass context other view controllers)

uimanaged document save context you.

take @ uimanageddocument documentation configure persistent store options (you send nsdictionary of options uimanageddocument instance, see first example through link below).

uimanageddocument documentation: http://developer.apple.com/library/ios/#documentation/uikit/reference/uimanageddocument_class/reference/reference.html

also see coredata lecture , demo (lectures 13 , 14) of iphone , ipad application development course paul hegarty available free on itunesu (fall 2011).


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -