繁体   English   中英

从不兼容的指针类型初始化

[英]initialization from incompatible pointer type

-(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 的新手......过去几周一直在学习这个,试图抓住它......无论如何,请帮助我解决这个问题。 我了解整个代码,但我不明白为什么 inheritance 有问题。

提前致谢

如果它说一个 class 可能没有响应选择器,这意味着它无法找到选择器的方法声明。 您是否在DatabaseTestAppDelegate的标头( ".h" )文件中声明了方法+(sqlite3 *)getNewDBConnection

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM