-(void)initializeTableData
{
sqlite3 *db=[DatabaseTestAppDelegate getNewDBConnection];
sqlite3_stmt *statement=nil;
const char *sql="select * from WhereTo";
if (sqlite3_prepare_v2(db, sql, -1, &statement, NULL)!=SQLITE_OK)
NSAssert1(0,@"error in preparing staement",sqlite3_errmsg(db));
else {
while(sqlite3_step(statement)==SQLITE_ROW)
[tableData addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement,1)]];
}
sqlite3_finalize(statement);
}
在sqlite3 *db=[DatabaseTestAppDelegate getNewDBConnection];
< ---它说,DatabaseTestAppDelegate可能无法响应'+ getNewDbConnection'
这是我的getNewDbConnection
+(sqlite3 *) getNewDBConnection{
sqlite3 *newDBconnection;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Malacca-lah.sqlite"];
// Open the database. The database was prepared outside the application.
if (sqlite3_open([path UTF8String], &newDBconnection) == SQLITE_OK) {
NSLog(@"Database Successfully Opened :)");
}
else {
NSLog(@"Error in opening database :(");
}
return newDBconnection;
}
我是XCode和SQLite的新手......过去几周一直在学习这个,试图抓住它...无论如何,请帮我解决这个问题。我理解整个代码,但我不明白为什么继承有问题。
提前致谢
答案 0 :(得分:0)
如果它说某个类可能没有响应选择器,则意味着它无法找到选择器的方法声明。您是否在+(sqlite3 *)getNewDBConnection
的标题(DatabaseTestAppDelegate
)文件中声明了方法".h"
?