On Mar 13, 2014, at 13:09 , Bradley O'Hearne <[email protected]> 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



Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to