1

我正在尝试在我的班级分配的集合视图单元格中填充 twitter 信息,每次我尝试这样做时,我的应用程序都会因以下错误而崩溃:
Thread 6: EXC_BAD_INSTRUCTION (code=EXC_1386_INVOP)
以及调试窗口中显示的此语句:
-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0xa5744b0
我可以使用什么解决方案来纠正此错误?
在这里查看我的整个项目是我指向整个项目的 Dropbox 链接

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
  // here I am creating my cell for the custom View
  CustomCollectionCellView *cellCollect = [theCollectionView dequeueReusableCellWithReuseIdentifier:@"customCell" forIndexPath:indexPath];
  if (cellCollect != nil)
 {
    NSDictionary *userTweetDictionary = [usertwitterfeed objectAtIndex:indexPath.row];
    if (userTweetDictionary != nil)
    {
        cellCollect.userNameLabel.text = (NSString *)[userTweetDictionary objectForKey:@"screen_name"];
        //cellCollect.dateLabel.text = (NSString *)[tweetDictionary objectForKey:@"created_at"];
    }
    return cellCollect;
  }

  return nil;
}
4

1 回答 1

1

很少需要更改。首先制作usertwitterfeed一个NSDictionary对象而不是NSArray

然后

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    // here I am creating my cell for the custom View
    CustomCollectionCellView *cellCollect = [theCollectionView dequeueReusableCellWithReuseIdentifier:@"customCell" forIndexPath:indexPath];
    if (cellCollect != nil)
    {

        if (usertwitterfeed != nil)
        {
            cellCollect.userNameLabel.text = (NSString *)[usertwitterfeed objectForKey:@"screen_name"];
        }
        return cellCollect;
    }

    return nil;
}
于 2013-05-16T15:23:53.573 回答