Re: Removing Core Data from an existing app
Re: Removing Core Data from an existing app
- Subject: Re: Removing Core Data from an existing app
- From: "Bradley O'Hearne" <email@hidden>
- Date: Thu, 13 Mar 2014 13:09:19 -0700
On Mar 13, 2014, at 12:51 PM, Bradley O'Hearne <email@hidden> wrote:
Ugh, my apologies for a cut/paste that lost its formatting. I didn’t even realize it until I received the message from the list. Here’s the original message again, this time with proper formatting:
I have an existing iOS app which is available in the iTunes App Store which employs Core Data for persistence (SQLLite). I am overhauling the persistence model in the app, and so the big picture is that I need to migrate all data (if it exists) into the new persistence model (the specifics of the new model are unimportant). Because I have to handle both new users of the app, and users who have the app already, this breaks down to the following use case:
1. Determine if the user is a new user of the app, or an existing user of the app. I would assume the proper way to determine this is to detect if a Core Data database exsts (without creating one, of course). If it does exist, then the user is an existing user, and go to step 2. If it does not exist, then the user is a new user, go to step 4.
2. This is an existing user, so load the Core Data database, read all data out, store in the new persistence model.
3. Delete the existing Core Data database file from the filesystem
4. Store some state value in NSUserDefaults indicating that the user is migrated / Core Data has been removed / doesn’t exist.
5. For all subsequent app launches, check the NSUserDefaults for the state variable indicating no other checks need to be done.
6. Use the new persistence model.
I have three questions about facilitating the above:
1. How do I check for the presence of a Core Data database without actually instantiating / creating the database?
2. After using an existing Core Data database, what is the proper way to completely unload it from memory and then delete the database file entirely?
3. Is there a better way to go about accomplishing the above?
Thanks,
Brad
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden