Re: sqlite iphone question....
Re: sqlite iphone question....
- Subject: Re: sqlite iphone question....
- From: James Cicenia <email@hidden>
- Date: Fri, 23 Jan 2009 11:52:12 -0600
Hmmm,,, newbie here..
Where is the "sandbox?
Thanks
James
On Jan 23, 2009, at 11:39 AM, Keary Suska wrote:
On Jan 23, 2009, at 10:30 AM, James Cicenia wrote:
- (void)initializeDatabase {
NSMutableArray *items = [[NSMutableArray alloc] init];
self.produceItems = items;
[items release];
// The database is stored in the application bundle.
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory
stringByAppendingPathComponent:@"whatsfresh.sqlite"];
// Open the database. The database was prepared outside the
application.
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSLog(@"Open Database");
// Get the primary key for all produce.
const char *sql = "SELECT id FROM Item";
sqlite3_stmt *statement;
// Preparing a statement compiles the SQL query into a byte-
code program in the SQLite library.
// The third parameter is either the length of the SQL string
or -1 to read up to the first null terminator.
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL)
== SQLITE_OK) {
NEVER GETS PAST THIS IF. I have queried the database and the data
is in there?!
Working with files in the app bundle like this may be a non-no. At
least, it is for Mac OS X, and the emulator might have this issue.
To know for sure, put the database file into the "sandbox" and see
if it behaves better there.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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