Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First parameter name in objective c?

Tags:

I have a method:

- (void)pan:(double)lat longitude: (double) lon{...}

When I call it Xcode shows to like this:

[self pan:(double) longitude:(double)]

Isn't it possible to set first parameter somehow, like the second (longitude), that Xcode could show like this:

[self pan: latitude:(double) longitude:(double)]

It is very annoying for me that I can not see the name of the first parameter when calling. Is it my fault or it is impossible?

like image 835
Tom Avatar asked Jan 07 '12 18:01

Tom


People also ask

What is argument label?

The argument label is used when calling the function; each argument is written in the function call with its argument label before it. The parameter name is used in the implementation of the function. By default, parameters use their parameter name as their argument label.

Does Objective-c have function overloading?

Correct, objective-C does not support method overloading, so you have to use different method names.

What should we use as the argument label name in a function's prototype if we don't want the user to provide a parameter name when calling it?

To omit argument labels, use a _ before the parameter name. A parameter name is still necessary to access the argument's value inside the function. Omitting the argument label might be wanted to make the function more readable.


1 Answers

The normal way to do what you're asking is to declare your method like:

-(void)panLatitude:(double)lat longitude:(double)lon; 

That is, include the label for the first argument with the method name at the beginning. You'd use it like:

[self panLatitude:x longitude:y]; 
like image 79
Carl Norum Avatar answered Sep 28 '22 04:09

Carl Norum