当我尝试运行程序时出现以下错误。我得到它的任何理由?我已经尝试了几个小时,但我放弃了。谢谢!
错误:
2011-03-08 19:18:29.967 iphoneApp [2561:207] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'* + [NSString stringWithUTF8String:]:NULL cString “
- (AnswerDTO *)findAnswerById:(NSInteger)primary_key {
AnswerDTO *dto = [[[AnswerDTO alloc] init] autorelease];
sqlite3_stmt *statement = nil;
const char *sql = "SELECT * FROM klb_answers WHERE id = 7;";
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
sqlite3_bind_int(statement, 1, primary_key);
NSInteger answerId = sqlite3_column_int(statement, ANSWER_ID);
NSInteger answerQuestionId = sqlite3_column_int(statement, ANSWER_QUESTION_ID);
NSString *answerDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, ANSWER_DESCRIPTION)];
NSString *answerSerialNumber = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, ANSWER_SERIAL_NUMBER)];
NSInteger answerIsCorrect = sqlite3_column_int(statement, ANSWER_IS_CORRECT);
dto.answerID = answerId;
dto.questionID = answerQuestionId;
dto.description = answerDescription;
dto.serialNumber = answerSerialNumber;
if (answerIsCorrect == 0) {
dto.isCorrect = NO;
} else {
dto.isCorrect = YES;
}
} else {
NSLog(@"Noe feil med statementet");
}
sqlite3_finalize(statement);
return dto;
}
答案 0 :(得分:2)
看起来你并没有“运行”你的查询。你准备好它并绑定了你的params,但是你从未运行sqlite3_step()来执行查询并获得响应。即使它是单个记录或标量。
结果,您的列函数返回空值。