uitableview 滑動時 報錯-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance


出現此問題的解決辦法是:

  1. 問題:  
  2. 新建一個tableview,在設置數據源時,如果不retain一下數組的話,就會崩潰:  
  3. array = [NSArray arrayWithObjects: @"1",@"2",@"3",@"4",@"5", nil];  
  4. [array retain];  
  5. 報錯信息:  
  6.  -[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x4b436d0  
  7. 新建tableview最精簡的代碼:  
  8. - (void)viewDidLoad  
  9. {  
  10.     [super viewDidLoad];  
  11.       
  12.     UITableView *tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]  
  13.                                                           style:UITableViewStylePlain];  
  14.       
  15.     tableView.delegate = self;  
  16.     tableView.dataSource = self;  
  17.       
  18.     array = [NSArray arrayWithObjects: @"1",@"2",@"3",@"4",@"5", nil];  
  19.     [array retain];  
  20.       
  21.     self.view = tableView;  
  22.     [tableView release];  
  23.    
  24. }  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM