出現此問題的解決辦法是:
- 問題:
- 新建一個tableview,在設置數據源時,如果不retain一下數組的話,就會崩潰:
- array = [NSArray arrayWithObjects: @"1",@"2",@"3",@"4",@"5", nil];
- [array retain];
- 報錯信息:
- -[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x4b436d0
- 新建tableview最精簡的代碼:
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- UITableView *tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]
- style:UITableViewStylePlain];
- tableView.delegate = self;
- tableView.dataSource = self;
- array = [NSArray arrayWithObjects: @"1",@"2",@"3",@"4",@"5", nil];
- [array retain];
- self.view = tableView;
- [tableView release];
- }