I am currently using mysql database at server and for local sqlite in 开发者_JS百科my application. I am facing lots problem in local database. Sometime database lock, unable to update etc.
Is there any other option than Core data and Sqlite for storing data locally in Mac application?
Just replacing one database with another is unlikely to fix locking problems. SQLite and CoreData (which often uses SQLite) are solid technologies that are used by many, if not most, Mac applications.
Without more information about the locks you're experiencing, I'd suggest that it's more likely that you're using the database incorrectly. Are you trying to access the database from multiple-threads? Are you correctly closing prepared statements?
You could continue to use Core Data but use a different Storage Backend, e.g., the Binary one (which should be less problematic concerning locking and transaction safety in general). See the Core Data Programming Guide for the different kinds of Persistent Store Coordinators.
Regarding Stephen Darlington's Answer: I don't quite agree. Depending on the Concurrency Control in SQLite (most probably Optimistic Concurrency Control) a transaction may be aborted because it modifies data that is currently "in use". This may happen at the granularity of a database of even a single relation. Using a "less transaction safe" backend like the binary store may already be sufficient in this case. This puts the burden on you to manage consistency but if you are sure your transactions don't conflict you should be fine.
I'd say that Core Data is the best one. Why don't you use this? You can also save things in XML. This is quite handy to save some small things. You can save a dicitionary for example like this:
[dict writeToFile:@"YOUR_PATH" atomically:NO];
You are able to get the dictionary again by implementing:
NSDicionary* dict = [NSDictionary dictionaryWithContentsOfFile:@"YOUR_PATH"];
精彩评论