Re: Why doesn't this work on my device?
Re: Why doesn't this work on my device?
- Subject: Re: Why doesn't this work on my device?
- From: Bill Bumgarner <email@hidden>
- Date: Fri, 27 Feb 2009 08:35:57 -0800
On Feb 27, 2009, at 7:56 AM, James Cicenia wrote:
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory
stringByAppendingPathComponent:@"whatsfresh.sql"];
int cntv = 0;
int cntf = 0;
ProduceItem *item=nil;
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
// Get the primary key for all books.
const char *sql = "SELECT type, subtype, name, id FROM
ProduceItem ORDER BY name";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) ==
SQLITE_OK) {
It does get to the second If statement so it did find the database.
But then evidently it is not SQLITE_OK on my device in regards to
that last if.
Have you checked to see if the file at path actually exists?
The documentation for sqlite3_open() indicates that it will quite
happily create a band new empty database if one doesn't exist at the
path.
Have a look at the SQLite Book List example (http://developer.apple.com/iphone/library/samplecode/SQLiteBooks/listing4.html
) as it demonstrates testing for the database file and then copying it
into the writable location, as necessary.
b.bum
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden