Atma Atma - 7 months ago 33
Objective-C Question

How do I pass multiple parameters in Objective-C?

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

parameters and a return type of
. 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

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,

getBusStops: forTime:

is the name of the method. The name is broken up so it can be more descriptive. You could simply name your method

getBusStops: :

but that doesn't tell you much about the second parameter.