lundi 25 mai 2015

sqlite3_stmt gives Exc_Bad_Access

This is the code I use AFSQLManager in here any help how to solve this: ![this is where I get the Thread and note when I do not comment the if condition it dose not inter the inside the if condition I also try to NSLog the statement before inter the if condition and give me the same thread any help ][1]

-(void)performQuery:(NSString *)query withBlock:(completionBlock)completion {

    NSString *fixedQuery = [query stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];

    NSLog(@"HERE 100d : %@",fixedQuery);

    sqlite3_stmt *statement;

   // if (sqlite3_prepare_v2(_database, [fixedQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {

        // NSLog(@"HERE 100a : %@", statement);

        while (sqlite3_step(statement) == SQLITE_ROW) {  //HERE WHERE I GOT THE THREAD.

            NSMutableArray *row = [NSMutableArray array];
             NSLog(@"HERE 100b");
            for (int i = 0; i < sqlite3_column_count(statement); i++) {
                NSLog(@"HERE 100c");
                [row addObject:((char *)sqlite3_column_text(statement, i)) ? [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, i)] : [NSNull null]];
            }

            if (completion) {
                NSLog(@"HERE 100e");
                completion(row, nil, NO);
            }
        }
        NSLog(@"HERE 100f");

        sqlite3_finalize(statement);
        completion(nil, nil, YES);
        NSLog(@"HERE 100g");
   // }
    NSLog(@"HERE 100h");
}

Aucun commentaire:

Enregistrer un commentaire