- (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;
}
RSS の空の行を取得しようとすると問題が発生します (Web カテゴリに投稿がありません)
アラートを表示して自動的にメイン ページに移動したい。
ここに立ち往生。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[self getLoadingTableCellWithTableView:tableView];
RssItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RssItemCell"];
@try {
NSLog(@"Trying to tetch");
// If break in here, url fetch maybe error or empty row
RssItem *feed = [[self.manager.feeds objectForKey:self.manager.currentChannel] objectAtIndex:indexPath.row];
cell.title.text = feed.title;
cell.description.text = feed.description;
[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;
}
@catch (NSException *e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",e] delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
TableViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
[self presentViewController:VC animated:YES completion:nil];
}
@finally {
NSLog(@"finally");
}
}
アラートが表示されず、ブレークポイントに移動します。このエラーをどのように処理すればよいですか?