Tito Ciuro
2011-01-31 19:38:57 UTC
Hello,
The following code snippet runs fine on Mac OS X, but fails on the iOS simulator:
// Obtain a path for the database
NSString *docs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *path = [[docs stringByAppendingPathComponent:@"myDB.sqlite"]fileSystemRepresentation];
// Open the database
sqlite3 *db = NULL;
int statusOpen = sqlite3_open_v2( fileSystemRepresentation, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_AUTOPROXY | SQLITE_OPEN_FULLMUTEX, NULL);
// Build the first statement
sqlite3_stmt *oneStatement = NULL;
const char *oneSQL = [[NSString stringWithFormat:@"INSERT INTO %@(%@, %@, %@, %@) VALUES (?,?,?,?);", NSFValues, NSFKey, NSFAttribute, NSFValue, NSFDatatype]UTF8String];
int statusOne = sqlite3_prepare_v2(db, oneSQL, (int)strlen(oneSQL), &oneStatement, &oneSQL);
// Build the second statement
sqlite3_stmt *twoStatement = NULL;
const char *twoSQL = [[NSString stringWithFormat:@"INSERT INTO %@(%@, %@, %@, %@) VALUES (?,?,?,?);", NSFKeys, NSFKey, NSFPlist, NSFCalendarDate, NSFObjectClass]UTF8String];
int statusTwo = sqlite3_prepare_v2(db, twoSQL, (int)strlen(twoSQL), &twoStatement, &twoSQL);
What I see is that statusTwo returns 1, and I have no idea why. What is really puzzling is that if I open the database in memory or temporary mode, it works fine in both Mac OS X and iOS!
So my question I have is, why would the second sqlite3_prepare_v2 statement fail only on path-based iOS apps? :-/
Thanks in advance,
-- Tito
The following code snippet runs fine on Mac OS X, but fails on the iOS simulator:
// Obtain a path for the database
NSString *docs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *path = [[docs stringByAppendingPathComponent:@"myDB.sqlite"]fileSystemRepresentation];
// Open the database
sqlite3 *db = NULL;
int statusOpen = sqlite3_open_v2( fileSystemRepresentation, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_AUTOPROXY | SQLITE_OPEN_FULLMUTEX, NULL);
// Build the first statement
sqlite3_stmt *oneStatement = NULL;
const char *oneSQL = [[NSString stringWithFormat:@"INSERT INTO %@(%@, %@, %@, %@) VALUES (?,?,?,?);", NSFValues, NSFKey, NSFAttribute, NSFValue, NSFDatatype]UTF8String];
int statusOne = sqlite3_prepare_v2(db, oneSQL, (int)strlen(oneSQL), &oneStatement, &oneSQL);
// Build the second statement
sqlite3_stmt *twoStatement = NULL;
const char *twoSQL = [[NSString stringWithFormat:@"INSERT INTO %@(%@, %@, %@, %@) VALUES (?,?,?,?);", NSFKeys, NSFKey, NSFPlist, NSFCalendarDate, NSFObjectClass]UTF8String];
int statusTwo = sqlite3_prepare_v2(db, twoSQL, (int)strlen(twoSQL), &twoStatement, &twoSQL);
What I see is that statusTwo returns 1, and I have no idea why. What is really puzzling is that if I open the database in memory or temporary mode, it works fine in both Mac OS X and iOS!
So my question I have is, why would the second sqlite3_prepare_v2 statement fail only on path-based iOS apps? :-/
Thanks in advance,
-- Tito