开发者

Embedding a predefined SQLITE doc in Core Data Application

开发者 https://www.devze.com 2022-12-08 09:49 出处:网络
Thanks for the help. I have a woking Core Data doc based app. that solely supports SQLITE docs. I would like to distribute the application with a previously created database document with predefined d

Thanks for the help. I have a woking Core Data doc based app. that solely supports SQLITE docs. I would like to distribute the application with a previously created database document with predefined data embedded in the application bundle.

How do I instruct the applicati开发者_如何学JAVAon to run the embedded file at runtime?

thanks.

-paul.


Generally, what you'd do is store a copy of the file in the Resources directory of your application bundle. From there, it depends on what kind of application you have. If it's a single document application (like iPhoto, for example), You could copy the file to the ~/Application Support/Your Application directory so that your app will open it by default.

Take a look inside the application delegate class (I'm assuming you're using the template provided with Xcode?) to see how it generates the path to the application file. You basically just have to make sure that the file exists at that path when the application starts up.

In this case, NSFileManager and the pathForResource:ofType: method of NSBundle are your friends.

0

精彩评论

暂无评论...
验证码 换一张
取 消