Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 已将无法识别的选择器发送到实例_Iphone_Ios4_Ios 4.2 - Fatal编程技术网

Iphone 已将无法识别的选择器发送到实例

Iphone 已将无法识别的选择器发送到实例,iphone,ios4,ios-4.2,Iphone,Ios4,Ios 4.2,我正在创建一个示例应用程序,其中我正在读取数据库并将用户图像和名称显示到tableview中。 但我有以下例外 [UIApplication userListMutableArray]: unrecognized selector sent to instance 0x6816330 下面是我的代码片段 AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication]; if(sqlite3_open([db

我正在创建一个示例应用程序,其中我正在读取数据库并将用户图像和名称显示到tableview中。 但我有以下例外

[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]


上面的行给出了异常,但我无法跟踪问题:(

您的appDelegate变量指向UIApplication,而不是其委托属性。请更改此分配

AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication];


更改以下行

AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication];

可能重复的
AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication];
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];