开发者

Variable Not a CFString

I am using a database to populate a table view.

I created an NSMutable Array of object in the AppDelegate. The Array is populated from the DB as follows:

if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
    const char *sql = "select barcode, vintage, vineyard, varietal from wine";
    sqlite3_stmt *statement;
    if(sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
        while(sqlite3_step(statement) == SQLITE_ROW) {
            NS开发者_运维技巧String *barcode = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)];
            DBHelper *wineObj = [[DBHelper alloc] initWithBarcode:barcode];
            wineObj.vintage = sqlite3_column_int(statement, 1);
            wineObj.vineyard = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)];
            wineObj.varietal = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 3)];

            [appDelegate.wineList addObject:wineObj];
            [wineObj release];
        }
    }
}

All of the data goes into the array correctly with barcode being of type NSString *. However, when the table view is displayed, the barcode turns into "Variable Not a CFString." When I select an item, I am using:

//get the bottle details for selected object
DBHelper *tempObj = [appDelegate.wineList objectAtIndex:indexPath.row];
DBHelper getBottleDetails:[appDelegate getDBPath]:tempObj.barcode];

Because the barcode is not longer being interpreted as an NSString, the app crashes. How do I ensure that the barcode remains valid to use?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜