首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带有NSInvocation方法参数的函数

带有NSInvocation方法参数的函数
EN

Stack Overflow用户
提问于 2009-12-22 10:59:27
回答 1查看 459关注 0票数 0

我有一个正在使用这两个函数的控制器视图:

代码语言:javascript
复制
[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中,下面是第二个函数的细节:

代码语言:javascript
复制
- (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转换我的代码。有人能帮我吗?

诚挚的问候,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-12-22 11:14:39

您可能会遇到的问题是您的预准备语句在sqlite3_close之后是无效的。每次打开数据库时,都需要创建一个新的预准备语句。

使用sqlite3_open.

  • Prepare打开数据库,使用sqlite3_bind.

  • Step和朋友执行语句。
  1. 使用sqlite3_bind.
  2. Step绑定
  3. 确保您使用sqlite3_close.

调用sqlite3_finalize.

  • Close数据库

您不能只是重置语句,因为该语句是为不同的数据库句柄准备的。

注意:

我对SQLite不是很熟悉。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1943922

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档