我有一个正在使用这两个函数的控制器视图:
[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];所以在我的ressourceManager中,下面是第二个函数的细节:
- (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);
}问题是第二个函数不工作(librairies例程调用顺序错误),因为我已经以相同的方式调用了第一个函数(我希望能够在同一时间内使用参数执行许多查询)。我听说使用NSInvocation可以解决这个问题,但我不知道如何使用NSInvocation转换我的代码。有人能帮我吗?
诚挚的问候,
发布于 2009-12-22 11:14:39
您可能会遇到的问题是您的预准备语句在sqlite3_close之后是无效的。每次打开数据库时,都需要创建一个新的预准备语句。
使用sqlite3_open.
sqlite3_bind.
sqlite3_bind.sqlite3_close.调用sqlite3_finalize.
您不能只是重置语句,因为该语句是为不同的数据库句柄准备的。
注意:
我对SQLite不是很熟悉。
https://stackoverflow.com/questions/1943922
复制相似问题