뷰가로드되어 NSMutableArray에 호출 내용을 저장할 때 웹 서비스를 호출하는 경우가 있습니다. 그런 다음 cellForRowAtIndexPath에서이 배열에서 행을 검색합니다. 나는 그러나, indexPath에서 행 인덱스를 얻을 수있는 해킹 기분을 사용indexPath의 행 인덱스
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
<snip cell alloc stuff>
// Configure the cell.
unsigned int *indexes = (unsigned int*)calloc([indexPath length], sizeof(unsigned int));
[indexPath getIndexes:indexes];
Tasks *task = [_tasksArray objectAtIndex:indexes[1]];
free(indexes);
cell.textLabel.text = [task getname];
cell.detailTextLabel.text = [NSString stringWithFormat:@"Started: %@", [task getstarted] ? [[task getstarted] description] : @"Not Yet"];
return cell;
}
이 작업을 수행 할 수있는 더 나은 방법이 있나요?
쿨, 고마워. 나는 그것이 쉽다는 것을 알고 있었지만 NSIndexPath의 내부에 대해 읽었으며 속성을 보지 못했습니다. –
NSIndexPath를 검색 할 경우 설명서에 NSIndexPath Class Reference가 첫 번째로 표시되어 오해의 소지가 있습니다. –