저는 Objective C와 iOS를 처음 접했습니다. 스토리 보드에 View Controller에 탐색 컨트롤러를 내장했습니다. 그런 다음 스토리 보드에 다른보기 컨트롤러 (루트보기 컨트롤러)를 추가했습니다. 그것은 테이블보기가 추가 된 다른보기 컨트롤러에 연결하는 단추가 있습니다. 빌드를 실행할 때 'NSInvalidArgumentException'이유 : '- [UIViewController tableView : numberOfRowsInSection :] : 인식 할 수없는 선택기가 인스턴스 0x686d160으로 전송되었습니다'라는 예외가 발생합니다. 당신은 해제 된 연락처 변수에 '수'메시지를 보내는UITable보기에 관한 예외
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [contacts count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"RecipeCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [contacts objectAtIndex:indexPath.row];
return cell;
}
연락처 배열에 값이 있습니까? – Dolo
그것은'contacts' 배열에 empty 나 null과 같은 몇몇 잘못된 값이 있음을 분명히 보여줍니다. 그래서 그것이 null이 아니며 값이 있는지 확인하십시오. – iEngineer
메시지를 nil 개체로 보낼 수는 있지만 할당되지 않은 개체로 메시지를 보낼 수는 없습니다. – Jeremy