Core Data Store included in App Bundle

后端 未结 3 999
天命终不由人
天命终不由人 2020-12-09 06:02

I can\'t find a clear description of these steps in Apple docs...

  1. I have a xcdatamodeld in my xcode project
  2. At launch time, my app parses a XML (proje
3条回答
  •  甜味超标
    2020-12-09 06:43

    1. Write a utility app using the data model and classes for the app. Use the utility app to generate a persistent store from the data provided by the XML.
    2. Add the store file to the app bundle like any other resource
    3. Pick a location in the app directory where you want the active store to reside e.g. the Library directory.
    4. Upon launch have the app check if the store is present in directory. If it isn't, the app should copy the store from the app bundle to the directory using standard NSFileManger methods just like any other file. (Usually, you only need to do this the first time the store is created. )

    That's all there really is to it.

提交回复
热议问题