我正在创建一个样例应用程序,其中我正在读取数据库并将用户图像和名称显示到表视图中。但是我遇到了以下异常:
[UIApplication userListMutableArray]: unrecognized selector sent to instance 0x6816330
以下是我的代码片段
AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication];
if(sqlite3_open([dbPath UTF8String], &database)==SQLITE_OK)
{
const char *sql = "select NAME,IMAGE from user";
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL)==SQLITE_OK)
{
while (sqlite3_step(selectstmt) == SQLITE_ROW) {
UserData *userData = [[UserData alloc] init];
userData.userName = [NSString stringWithUTF8String:(char*)sqlite3_column_text(selectstmt, 0)];
NSData *data = [[NSData alloc] initWithBytes:sqlite3_column_blob(selectstmt, 1) length:sqlite3_column_bytes(selectstmt, 1)];
if(data == nil)
NSLog(@"image not found");
userData.userImage = [UIImage imageWithData:data];
**[appDelegate.userListMutableArray addObject:userData];**
}
}
}
else
{
sqlite3_close(database);
}
[appDelegate.userListMutableArray addObject:userData];
以上代码出现了异常,但我无法找出问题。:(