I have a controller view who is using thoses 2 functions:
[appDelegate getFichesInfo:[[self.fichesCategory idModuleFiche] intValue] ]; //first function
self.fiche = (Fiche *)[appDelegate.fichesInfo objectAtIndex:0];
[appDelegate getFichesVisuels:[[self.fiche idFiche] intValue] ]; //second function not working
self.fiche = (Fiche *)[appDelegate.fichesInfo objectAtIndex:0];
So in my ressourceManager, here is the 2nd function in details:
- (void)getFichesVisuels:(int)value {
fichesVisuels = [[NSMutableArray alloc] init];
sqlite3 *database;
if(sqlite3_open([self.databasePath UTF8String], &database) == SQLITE_OK) {
sqlite3_reset(getFichesVisuelsStatement);
sqlite3_bind_int(getFichesVisuelsStatement, 1, value);
while(sqlite3_step(getFichesVisuelsStatement) == SQLITE_ROW) {
NSString *aTitle = [NSString stringWithUTF8String:(char *)sqlite3_column_text(getFichesVisuelsStatement , 7)];
NSString *aLpath = [NSString stringWithUTF8String:(char *)sqlite3_column_text(getFichesVisuelsStatement , 8)];
Visuel *visuel = [[Visuel alloc] initWithName:aTitle lpath:aLpath];
[fichesVisuels addObject:visuel];
}
}
sqlite3_close(database);
}
The problem is that the 2nd function is not working (librairies routine called out of sequence) because I am already calling the 1st function in the same way (I wanna be able to execute many query using arguments in the same times). I heard that using NSInvocation can be the solution to this problem, but I don't know how to turn my code using NSInvocation. Someone can help me?
Best Regards,
The problem you could be having is that your prepared statement is invalid after sqlite3_close
. You need to create a new prepared statement each time you open the database.
sqlite3_open
.sqlite3_prepare
and friends.sqlite3_bind
.sqlite3_step
.sqlite3_finalize
.sqlite3_close
.You can't just reset the statement, because that statement was prepared for a different database handle.
I'm not too familiar with SQLite.