我的应用程序在iOS 7上完美运行,但在iOS 8上,我选择它不能正常工作,我检查了iOS7和iOS8中sqlite3_prepare_v2的返回是不同的,请查看它。
ios7
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上
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
我得到了完全相同的代码,任何想法的日志?
我选择的代码是..
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)
{...
答案 0 :(得分:0)
问题是:
我从服务器下载基础并保存在Documents目录中的文件中。直到iOS7,我用来创建de文件路径以保存基础的方法还可以,但显然在iOS8上它不是..它正在保存一个空的数据库..
所以我使用另一种方法来创建文档的路径:
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];