Reputation: 2929
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?
Upvotes: 1
Views: 446
Reputation: 29333
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.
Upvotes: 1