2013-05-16 77 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

相關問題