I have read several of the post about Objective-C method syntax but I guess I don’t understand multiple names for a method.
I’m trying to create a method called getBusStops with NSString and NSTimeInterval parameters and a return type of NSMutableArray. This is how I have constructed the method but it obviously gets errors at runtime:
- (NSMutableArray *)getBusStops:(NSString *)busStop (NSTimeInterval *)timeInterval;
I saw another example with a method:
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
I don’t understand why this method has a method name for each parameter. Should I do the same with something like:
- (NSMutableArray *)getBusStops:(NSString *)busStop forTime:(NSTimeInterval *)timeInterval
Objective-C doesn’t have named parameters, so everything on the left side of a colon is part of the method name. For example,
is the name of the method. The name is broken up so it can be more descriptive. You could simply name your method
but that doesn’t tell you much about the second parameter.