以下語句有什麼問題?邏輯錯誤「未定義或垃圾值返回給調用者」
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *title;
switch (section)
{
case 0:
title = @"Section 1";
break;
case 1:
title = @"Section 2";
break;
default:
break;
}
return title;
}
爲什麼在分析此代碼時出現邏輯錯誤「Undefined or garbage value returned to caller」?
設置並返回int時,這也適用於heightForRowAtIndexPath。所以「int cellHeight;」將需要是「int cellHeight = 0;」類似於這個NSString的情況。 – whyoz