sqlite 在模拟器/设备上的差异

发布于 2024-10-20 18:12:48 字数 876 浏览 2 评论 0原文

我有一个应用程序从 SQLite 数据库中提取信息。它在 iPhone 模拟器上完美运行,但当我在设备上测试时,我没有得到任何结果。两者之间使用数据库有区别吗?我尝试到处寻找,但找不到任何有帮助的东西。我发现这个问题在谷歌上很常见,我只是还没有找到适合我的解决方案。

我已经设置了断点并尝试对此进行调试,在实际设备上它永远不会通过 while (sqlite3_step(statement) == SQLITE_ROW),它总是返回 SQLITE_DONE 。我不明白为什么这会在设备上发生变化。任何帮助,关于 SQLite 的建议,或者代码是否可以改进等等,我们将不胜感激。谢谢。

NSString *qsql = @"SELECT Distinct State FROM School";
    sqlite3_stmt *statement;

    if (sqlite3_prepare_v2(db, [qsql UTF8String], -1, &statement, nil) == SQLITE_OK) 
    {
        while (sqlite3_step(statement) == SQLITE_ROW) 
        {
            char *colState = (char *) sqlite3_column_text(statement, 0);
        NSString *state = [[NSString alloc] initWithUTF8String:colState];

        [states addObject:state];
        [state release];
    }
    sqlite3_reset(statement);
}
return states;

}

I have an app pulling information from a SQLite database. It works perfectly on the iPhone Simulator, but I don't get anything when I test on a device. Are there differences to using a database between the two? I've tried looking all over and can't find anything that is helping. I see this problem is common on google, I just haven't found a solution thats worked for me.

I have put break points in and tried to debug this, on the actual device it never gets passed while (sqlite3_step(statement) == SQLITE_ROW), it is always returning SQLITE_DONE. I can't figure out why this would change on a device. Any help would be appreciated, advice on SQLite, or if the code could be improved etc. Thanks.

NSString *qsql = @"SELECT Distinct State FROM School";
    sqlite3_stmt *statement;

    if (sqlite3_prepare_v2(db, [qsql UTF8String], -1, &statement, nil) == SQLITE_OK) 
    {
        while (sqlite3_step(statement) == SQLITE_ROW) 
        {
            char *colState = (char *) sqlite3_column_text(statement, 0);
        NSString *state = [[NSString alloc] initWithUTF8String:colState];

        [states addObject:state];
        [state release];
    }
    sqlite3_reset(statement);
}
return states;

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪淡了忧伤 2024-10-27 18:12:48

首先想到的是数据库在模拟器上安装正确,但在手机上安装不正确。

查看此答案看看是否对你有帮助。

The first thing that comes to mind is that the database is installed properly on the simulator but not on the phone.

Check out this answer to see if it helps you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文