sqlite3_prepare_v2在iOS7和iOS8上获得不同的回报

时间:2022-05-09 01:12:18

My app is working perfectly on iOS 7, but on iOS 8 my select it's not working and I checked that the return for sqlite3_prepare_v2 is different in iOS7 and iOS8, check it out..

我的应用程序在iOS 7上完美运行,但在iOS 8上我选择它不起作用我检查了sqlite3_prepare_v2的返回在iOS7和iOS8中有所不同,请查看它。

ios7

IOS 7

2014-09-19 09:18:08.841 Mapa Radar[511:60b] Database returned error 0: not an error
2014-09-19 09:18:08.841 Mapa Radar[511:60b] Database returned error 0: not an error
2014-09-19 09:18:08.974 Mapa Radar[511:60b] Accucary  5
2014-09-19 09:18:08.975 Mapa Radar[511:60b] SELECT * FROM Radares WHERE distance2(Latitude, Longitude, -23.111100, -46.849126)<1 ORDER BY distance2(Latitude, Longitude, -23.111100, -46.849126)
2014-09-19 09:18:08.975 Mapa Radar[511:60b] Database returned error 0: not an error

ios8

iOS8上

2014-09-19 09:14:51.631 Mapa Radar[609:76761] Database returned error 0: not an error
2014-09-19 09:14:51.633 Mapa Radar[609:76761] Database returned error 0: not an error
2014-09-19 09:14:52.252 Mapa Radar[609:76761] Accucary 65
2014-09-19 09:14:52.258 Mapa Radar[609:76761] SELECT * FROM Radares WHERE distance2(Latitude, Longitude, -23.516678, -47.477784)<1 ORDER BY distance2(Latitude, Longitude, -23.516678, -47.477784)
2014-09-19 09:14:52.259 Mapa Radar[609:76761] Database returned error 0: not an error
2014-09-19 09:14:52.261 Mapa Radar[609:76761] Database returned error 1: no such table: Radares

I got the Log for the exactly same piece of code, any ideas?

我得到了完全相同的代码,任何想法的日志?

the code for my select is..

我选择的代码是......

NSString *qsql= [NSString stringWithFormat:@"SELECT * FROM Radares WHERE distance2(Latitude,  Longitude, %@, %@)<1 ORDER BY distance2(Latitude, Longitude, %@, %@)",lat,longi,lat,longi];

NSLog(@"%@",qsql);

sqlite3_stmt *statement;

NSLog(@"Database returned error %d: %s", sqlite3_errcode(db), sqlite3_errmsg(db));

if (sqlite3_prepare_v2( db, [qsql UTF8String], -1,&statement, nil) == SQLITE_OK)
{
    while (sqlite3_step(statement) == SQLITE_ROW)
    {...

1 个解决方案

#1


0  

The problem was:

问题是:

I download the base from a server an save in a file on the Documents directory. Until iOS7 the method that I used to create de file path to save the base was ok, but apparently on iOS8 it isn't.. it was saving a empty database..

我从服务器下载基础并保存在Documents目录中的文件中。直到iOS7我用来创建de文件路径以保存基础的方法还可以,但显然在iOS8上它不是..它正在保存一个空数据库..

So i used another method to create the path to documents:

所以我使用另一种方法来创建文档的路径:

NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

//make a file name to write the data to using the documents directory:
NSMutableString *fileName = [NSMutableString stringWithFormat:@"%@/radares.db",
                             documentsDirectory];


NSLog(@"%@",fileName);

[_dados writeToFile:fileName atomically:YES];

#1


0  

The problem was:

问题是:

I download the base from a server an save in a file on the Documents directory. Until iOS7 the method that I used to create de file path to save the base was ok, but apparently on iOS8 it isn't.. it was saving a empty database..

我从服务器下载基础并保存在Documents目录中的文件中。直到iOS7我用来创建de文件路径以保存基础的方法还可以,但显然在iOS8上它不是..它正在保存一个空数据库..

So i used another method to create the path to documents:

所以我使用另一种方法来创建文档的路径:

NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

//make a file name to write the data to using the documents directory:
NSMutableString *fileName = [NSMutableString stringWithFormat:@"%@/radares.db",
                             documentsDirectory];


NSLog(@"%@",fileName);

[_dados writeToFile:fileName atomically:YES];