nicolas nicolas - 1 year ago 157
iOS Question

Xcode 7 Expected Expression Error

I have problem in iOS application development using sqlite.

When coding following code, there is an error on line

sqlite3_stmt *compiledStatement;
it says

"Expected Expression".

Please Help me find solution.

-(void)runQuery:(const char *)query isQueryExecutable:(BOOL)queryExecutable {

// Create a sqlite object.
sqlite3 *sqlite3Database;

//Set the database file path.
NSString *databasePath = [self.documentsDirectory stringByAppendingPathComponent:self.databaseFilename];

// Initialize the results array.
if (self.arrResults != nil){
[self.arrResults removeAllObjects];
self.arrResults = nil;

self.arrResults = [[NSMutableArray alloc] init];

// Initialize the column names array.
if (self.arrColumnNames != nil){
[self.arrColumnNames removeAllObjects];
self.arrColumnNames = nil;

self.arrColumnNames = [[NSMutableArray alloc] init];

// Open the database.
BOOL openDatabaseResult = sqlite3_open([databasePath UTF8String], &sqlite3Database);

if (openDatabaseResult == SQLITE_OK)
// Declare a sqlite3_stmt object in which will be stored the query after having been compiled into a SQLite statement.
sqlite3_stmt *compiledStatement;

// Load all data from database to memory.
BOOL prepareStatementResult = sqlite3_prepare_v2(sqlite3Database, query, -1, &compiledStatement, NULL);

if (prepareStatementResult == SQLITE_OK){

Answer Source

I doubt you want to create a pointer, I expect you want to create a struct variable as you then pass a pointer to it to the prepare function.

So you'd have sqlite3_stmt compiledStatement;

But, your issue appears to be that you've forgotten a bracket at the end of the if statement before that line.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download