Confusion regarding if and else part in navigation controller class in iPhone sdk
As we all know that the program flow either goes in if part or in else part(but never goes in both parts simultaneously). In the below code the flow is going inside both. I am unable to understand the reason behind.
- (NSInteger)tableView:(UITableVi开发者_如何学运维ew *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) {
NSLog(@"section1 count is %d",boys.count);
return boys.count;
}
else {
NSLog(@"section2 count1 is %d",girls.count);
return girls.count;
}
}
It goes inside both the blocks only if your table view contains more than 1 section and it goes either inside if block or else block per execution (it seems you have 2 sections).
Insert break points or log the section number before the if statements to make yourself clear.
精彩评论