开发者

initialization from incompatible pointer type

开发者 https://www.devze.com 2023-03-15 22:25 出处:网络
-(void)initializeTableData { sqlite3 *db=[DatabaseTestAppDelegate getNewDBConnection]; sqlite3_stmt *statement=nil;
-(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);
}

at sqlite3 *db=[DatabaseTestAppDelegate getNewDBConnection]; <--- it says, DatabaseTestAppDelegate may not respond to '+getNewDbConnection'

and here is my 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 :)");
    }
开发者_C百科    else {
        NSLog(@"Error in opening database :(");
    }
    return newDBconnection;
}

im new to XCode and also SQLite... been learning this for the past few weeks now, trying to get a hang on it... anyways, pls help me out with this problem. I understand the whole code but i dont understand why the inheritance has an issue.

Thanks in advance


If it says that a class may not respond to a selector, it means that it can not able to find the method declaration of the selector. Have you declared the method +(sqlite3 *)getNewDBConnection in DatabaseTestAppDelegate's header(".h") file?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号