これは簡単な質問です。次のコードで「コントロールが非void関数の終わりに到達する可能性があります」という警告が表示されるのはなぜですか。どのような状況で、2つのreturnステートメントのいずれかがヒットしませんか?return
2番目のステートメントをelse
ブロックの外に配置する方がより標準的なコーディング方法でしょうか?これは警告を沈黙させますが、なぜそれが存在するのか興味があります。
- (CGFloat) tableView: (UITableView *) tableView heightForRowAtIndexPath: (NSIndexPath *) indexPath
{
NSString *lineToFit = [[self.fetchedResultsController objectAtIndexPath: indexPath] line];
NSString *actorToFit = [[self.fetchedResultsController objectAtIndexPath: indexPath] actor];
CGSize lineSize = [lineToFit sizeWithFont: [UIFont boldSystemFontOfSize: 12.0f] constrainedToSize: CGSizeMake(320, 800)];
CGSize actorSize = [actorToFit sizeWithFont: [UIFont boldSystemFontOfSize: 12.0f] constrainedToSize: CGSizeMake(320, 800)];
if (shouldDisplayExtra) {
kExtraCellType cellType = [self cellIsGoingToContainExtraView];
if (cellType != kExtraCellTypeNone) {
[cellsToContainExtra setValue: [NSNumber numberWithInt: cellType] forKey: lineIDString];
return lineSize.height + actorSize.height + 200;
}
} else {
// Return the line height, actor height, plus a buffer.
return lineSize.height + actorSize.height;
}
}