My application currently uses CoreData as a backend to store to a single SQL data file stored in ~/Library/Application Support/MYAPP/MyDataFile.sqlite
. I know it's an unusual situation, but what is the best way to "lock" this file so that if the user decides (for whatever silly reason) to run a second copy of my app, Core Data won't freak out? Should I use something old school like writing a lockfile somewhere and checking for that, or is there a nicer more Cocoa way of doing this?
views:
23answers:
1
A:
As an alternative to locking the SQLite file, you could try using LSMultipleInstancesProhibited to disallow your users running two application instances.
Edit: the downside is it will also prevent multiple users (fast user switching) from using your application concurrently, although they do not share the core data store.
diciu
2009-12-13 16:35:20
Yeah, that's not quite what I need - I want users to be able to run my app in different accounts at the same time, just not at the same time. I think I will code something into the applicationWillFinishLaunching: method of my application delegate.
Tony Arnold
2009-12-14 01:40:40