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: Fri, 14 Mar 2014 11:18:38 -0700
On Mar 13, 2014, at 2:08 PM, Rick Mann <email@hidden> wrote:
>
> On Mar 13, 2014, at 13:09 , Bradley O'Hearne <email@hidden> wrote:
>
>> 1. How do I check for the presence of a Core Data database without actually instantiating / creating the database?
>
> You control where the actual file is created in your app, so I'd just check for the existence of that app to see if the user is using CD. Don't bother with NSUserDefaults.
>
> Also, the existence of data in your new persistence model can indicate you've done the conversion.
>
>> 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?
>
> If the file doesn't exist, don't make any references to the managed object context. The first time you do the conversion is the only time you'd have to worry about this, and you can probably ignore it. Next time the app terminates, it'll get flushed.
>
> However, some memory will be used in the meantime. If you're using ARC, set the CD stack objects (managed object context, model, and persistent store coordinator) to nil. That should get rid of all the references (assuming you don't keep any to the objects themselves).
>
> Lastly, ensure you can deal with a crash in the middle of the migration.
Rick — thanks for the helpful response. That last point about dealing with crashing makes good sense — rather than deal with the data completely in bulk, I think incremental migration and deletion of entities from Core Data would be the best idea. That way if there’s an interruption or crash, any app launch can pick up right where it left off.
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