NSDocument-based sqlite db read / write application

I am using a Mac OS X application for easy access to SQLite databases. Since the user will be able to work with a large number of files at the same time, I chose a document-based application.

Most books and manuals explain how to create and read data in this context from a file using NSData . My application should instead rely on the SQLite library for this purpose. What methods should I override to do this?

+4
source share
1 answer

Only -[NSDocument readFromURL:ofType:error:] . I believe that every change is saved automatically (SQLite), so you do not need a save action.

I did it too, and I really liked it.


For instance:

 - (BOOL)readFromURL:(NSURL *)URL ofType:(NSString *)type error:(NSError **)error { if (sqlite3_open_v2([[URL path] UTF8String], &db, SQLITE_OPEN_READWRITE, NULL) != SQLITE_OK) { sqlite3_close(db); return NO; } return YES; } 
+3
source

All Articles