2013-05-16 34 views
1

我想填充在集合视图细胞的Twitter信息,我的课堂作业,每次我试图用这个错误这样做,我的应用程序崩溃时错误:
Thread 6: EXC_BAD_INSTRUCTION (code=EXC_1386_INVOP)
以及调试窗口中显示的此语句:
-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0xa5744b0
我可以用什么解决方案来纠正这个错误?
要在这里看到我的整个项目是我的保管箱link to the entire project主题6:EXC_BAD_INSTRUCTION(代码= EXC_1386_INVOP)使用UICollectionWiew

- (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; 
} 
+0

'usertwitterfeed'是一个NSDictionary,而不是一个NSArray。 – CodaFi

回答

1

需要做些改变。首先,让usertwitterfeedNSDictionary对象,而不是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; 
} 
+0

非常感谢你,它不会崩溃。但现在的问题是如何让单元填充来自JSON twitter screen_name信息的信息。这是将这些信息从twitter发送到collectionView的目标。 – user2390364

相关问题