xcode的sqlite问题

时间:2011-03-25 23:10:15

标签: xcode ios sqlite

更新sqlite时,sigabrt崩溃了。在过去的3个小时里苦苦挣扎,接近重建,但我想先试试这里。使用在dblog.com.au上找到的优秀的sqlite / xcode tute,这里似乎崩溃了。谢谢!

-(void) readAnimalsFromDatabase {

sqlite3 *database;


animals = [[NSMutableArray alloc] init];if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {

    const char *sqlStatement = "select * from animals";
    sqlite3_stmt *compiledStatement;
    if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
    while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
NSString *fName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *fDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
NSString *fImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];
NSString *cName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 4)];
NSString *cDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 5)];
NSString *cImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 6)];

Animal *animal = [[Animal alloc] init: animal:fName description:fDescription url:fImageUrl cname:cName cdescription:cDescription cimageurl:cImageUrl];


[animals addObject:animal];

[animal release];
        }

0 个答案:

没有答案