sqlite3在iphone 3.1.2上的写权限问题

发布于 2024-08-10 00:06:31 字数 1240 浏览 5 评论 0原文

我目前正在为 iphone 开发一款游戏,其中图像从互联网加载,然后存储在本地数据库中,这样就不必再次加载。这一直运作良好。 最近,我为测试组创建了一个新的临时发行版(我第一次使用 SDK 3.1.2 创建发行版),现在每个将 iphone 升级到 3.1.2 的人都不再能够写入数据库,因此每次都必须从互联网加载图像。使用低于 3.1.2 的 iphone 版本的用户没有问题,之前构建的版本(使用 SDK 3.1 或更低版本)在 3.1.2 的 iphone 上也没有问题。 我对游戏所做的更新与游戏中的数据管理器无关。另一个奇怪的事情是,我使用以下代码在控制台中没有找到任何消息:

- (void) saveImage:(NSString *)imagePath withData:(NSData *)imageData {
    if (insert_image_statement == nil){
        const char *sql2 = "INSERT INTO image (imagePath, imageData) VALUES (?, ?);";
        if (sqlite3_prepare_v2(database, sql2, -1, &insert_image_statement, NULL) != SQLITE_OK) {
            NSLog(@"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
        }
    }
    sqlite3_bind_text(insert_image_statement, 1, [imagePath UTF8String], -1, NULL);
    sqlite3_bind_blob(insert_image_statement, 2, [imageData bytes], [imageData length], NULL);
    int success = sqlite3_step(insert_image_statement);
    if (success == SQLITE_ERROR){
        NSLog(@"Error: failed to insert statement with message '%s'.", sqlite3_errmsg(database));
    }
    sqlite3_reset(insert_image_statement);
}

因此 sqlite3 不会抛出错误,这可能会提示我解决此问题。有谁知道为什么使用 SDK 3.1.2 我似乎没有将数据写入数据库的权限?

I'm currently working on a game for the iphone, where images are loaded from the internet and then stored in the local database so they do not have to be loaded again. This has always worked fine.
Recently I created a new adhoc distribution for the testing group (the first time I created the distribution using SDK 3.1.2) and now everybody that has upgraded their iphone to 3.1.2 are no longer able to write to the database anymore, and thus have to load the images everytime from the internet. People with an iphone version lower than 3.1.2 have no problems and previously build versions (with SDK 3.1 or lower) have no problems on iphones with 3.1.2.
The updates I made to the game had nothing to do with the datamanager in the game. Another strange thing is that I do not find any messages in the console using the following code:

- (void) saveImage:(NSString *)imagePath withData:(NSData *)imageData {
    if (insert_image_statement == nil){
        const char *sql2 = "INSERT INTO image (imagePath, imageData) VALUES (?, ?);";
        if (sqlite3_prepare_v2(database, sql2, -1, &insert_image_statement, NULL) != SQLITE_OK) {
            NSLog(@"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
        }
    }
    sqlite3_bind_text(insert_image_statement, 1, [imagePath UTF8String], -1, NULL);
    sqlite3_bind_blob(insert_image_statement, 2, [imageData bytes], [imageData length], NULL);
    int success = sqlite3_step(insert_image_statement);
    if (success == SQLITE_ERROR){
        NSLog(@"Error: failed to insert statement with message '%s'.", sqlite3_errmsg(database));
    }
    sqlite3_reset(insert_image_statement);
}

So the sqlite3 does not throw an error which could point me towards the solution of this problem. Does anybody know why with SDK 3.1.2 I do not seem to have the permission to write the data to the database?

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

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

发布评论

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

评论(1

空‖城人不在 2024-08-17 00:06:31

这个问题解决了吗?我在 3.1.2 中的设备/发布版本中遇到类似的问题,其中 if(sqlite3_exec(...)); 中抛出错误语句,但没有返回错误消息。

********更新:通过修改引用以包含设备上的完整路径,达到了部分解决方案。谷歌“checkAndCreateDatabase”方法获取代码。我在 3.1.2 操作系统中的设备上的 sqlite 准备语句中仍然出现故障,而我在模拟器中没有。************

-(void)initializeDatabaseFunctions {

databaseName = "RowTable.db";
returnCode = sqlite3_open(databaseName, &sqlite);

NSString *dropRows = [[NSString alloc]initWithFormat:@"DROP TABLE IF EXISTS rows;"];
if(sqlite3_exec(sqlite, [dropRows UTF8String], NULL, NULL, &errorMsg) != SQLITE_OK) {
    NSLog(@"Error DROP TABLE IF EXISTS rows: %s", errorMsg);
sqlite3_free(errorMsg);}

was this issue resolved? I am having as similar problem with the Device/Release build in 3.1.2, where errors are thrown in the if(sqlite3_exec(...)); statement, but no error message is returned.

********UPDATE: a partial solution was reached by modifying the reference to include the full path on the device. Google "checkAndCreateDatabase" method for code. I still have failures in the sqlite prepare statement on the device in the 3.1.2 OS that I did not have in the simulator.**********

-(void)initializeDatabaseFunctions {

databaseName = "RowTable.db";
returnCode = sqlite3_open(databaseName, &sqlite);

NSString *dropRows = [[NSString alloc]initWithFormat:@"DROP TABLE IF EXISTS rows;"];
if(sqlite3_exec(sqlite, [dropRows UTF8String], NULL, NULL, &errorMsg) != SQLITE_OK) {
    NSLog(@"Error DROP TABLE IF EXISTS rows: %s", errorMsg);
sqlite3_free(errorMsg);}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文