Xcode 7预期表达式错误

时间:2016-06-05 18:51:57

标签: ios objective-c sqlite

我在使用sqlite开发iOS应用程序时遇到问题。

对代码进行编码时,行sqlite3_stmt *compiledStatement;上会出现错误,表示

  

"预期表达"。

请帮我找到解决方案。

-(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){
            ...
        }
    }

1 个答案:

答案 0 :(得分:0)

您的问题似乎是您在该行之前的if语句末尾忘记了一个括号。这个定义不足以在if语句中独立存在,并且你想要保护的不仅仅是定义。