我不知道我的程序中存在什么问题。运行此选择代码以从我的程序中的SQlite获取数据时,第一次崩溃时出现此错误消息:
杀死目标时杀死错误(无论如何都要杀):
警告:函数“macosx_kill_inferior_safe”中的“/SourceCache/gdb/gdb-1510/src/gdb/macosx/macosx-nat-inferior.c”第2179行出错:(os / kern)失败(0x5x)
退出
这是我的插入代码:
-(id)init {
self = [super init];
sqlite3 *database;
NSMutableArray *locations;
NSString *result = nil;
NSString *dbPath = [self getWritableDBPath];
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
{
NSString *sqlStr = [NSString stringWithFormat:@"select Longitude,Latitude from myLocation"];
const char *sqlStatement = [sqlStr UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
locations = [NSMutableArray array];
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
double longitude = sqlite3_column_double(compiledStatement, 0);
double latitude = sqlite3_column_double(compiledStatement, 1);
NSLog(@"%f , %f",longitude,latitude);
NSString *coords = [[[NSString alloc] initWithFormat:@"%f,%f\n",longitude,latitude] autorelease];
[locations addObject:coords];
NSLog(@"this location :-%@",locations);
//[coords release];
}
result = [locations componentsJoinedByString:@","]; // same as `fake_location`
NSLog(@"this for resulte data :- %@",result);
// Get file path here
NSError *error;
if ( [result writeToFile:dbPath atomically:YES encoding:NSUTF8StringEncoding error:&error] ) {
NSLog(@"%@", [error localizedDescription]);
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
pointsArray = [[result componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] retain];
pointsArrayIndex = 0;
oldLocationsIndex = 0;
[result release];
oldLocations = [[NSMutableArray alloc] init];
return self;
}
第二次运行我的应用程序时,它会在控制台上显示我:
保存错误:文件已加密或不是数据库
这些错误意味着什么,我该如何解决?
答案 0 :(得分:1)
您需要使用以下命令触发插入查询:
-(void)insertLocation:(double)latitude withLongitude:(double)longitude
{
sqlite3_stmt *insertStatement = nil;
const char *sql = "insert into UserJourneyLocation(Latitude, Longitude) Values(?,?)";
int returnValue = sqlite3_prepare_v2(database, sql, -1, &insertStatement, NULL);
if(returnValue == SQLITE_OK)
{
sqlite3_bind_double(insertStatement,1,latitude);
sqlite3_bind_double(insertStatement,2,longitude);
if(sqlite3_step(insertStatement)==SQLITE_DONE)
{
//Data;
}
}
sqlite3_finalize(insertStatement);
}
答案 1 :(得分:0)
是的,我有。
转到iphone应用程序文档文件夹
/ users /(yourname)/ library / application support / iphone simulator / user / application
并删除所有目标。之后重启您的应用程序。