阅读背景:

数组为空时的错误处理

来源:互联网 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self getLoadingTableCellWithTableView:tableView];

    RssItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RssItemCell"];
    // If break in here, url fetch maybe error or row is null
    RssItem *feed = [[self.manager.feeds objectForKey:self.manager.currentChannel] objectAtIndex:indexPath.row];

    cell.title.text = feed.title;
    cell.description.text = feed.description;
    cell.date.text = feed.date;
    // if any image enclosure at rss parse
    [cell.enclosure setImage:[UIImage imageNamed:@"logo.png"]];

    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
    dispatch_async(queue,
                   ^{
                       UIImage *image = [[UIImage alloc] initWithData:feed.enclosure];
                       [cell.enclosure  setImage:image];
                       [cell setNeedsLayout];
                   });

    return cell;
}
- (UITableViewCell *)tableView:(UITableView *)t



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: