indexPath的行索引

Jer*_*lin 6 objective-c ios

当视图加载并保存带有调用内容的NSMutableArray时,我经常调用Web服务.然后在cellForRowAtIndexPath中,我从这个数组中检索行.我使用感觉像黑客来从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;
}
Run Code Online (Sandbox Code Playgroud)

有一个更好的方法吗?

Nic*_*ver 13

尝试访问indexPath的行部分

indexPath.row
Run Code Online (Sandbox Code Playgroud)

这是Apple的NSIndexPath文档的链接.