Can someone explain this method declaration syntax for me? In this function, the number of rows of a UIPickerView (slot machine UI on the iPhone) is being returned. From my understanding, the Method is called 'pickerView
', and returns an NSInteger.
It passes in a pointer to the UIPickerview called 'pickerView
' ... first, why is the method called the same name as the parameter?
Next there is NSInteger parameter called component that tells us which component we are counting the rows for. The logic to decide which is in the body of the method.
What is 'numberOfRowsInComponent
? It seems to describe the value we are returning, but it is in the middle of the parameters.
- (NSInteger) pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
if (component == kStateComponent)
return [self.states count];
return[self.zips count];
}
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…