Objective-C syntax clarification

I am new to Objective-C and I am going through a tutorial that I found on the Internet . The tutorial discusses the separation of messages and argument sections and provides an example:

If there is more than one argument, they are declared in the method name after the colons. Arguments break the name in the declaration, as in the message.

- (void)setWidth:(float)width: height:(float)height;

I don't think there may be a colon after the width, but I could be wrong. From what I researched, I think this is a typo, but since I'm new, I just wanted to check.

Is the method simple setWidth: height:? Or is there another argument after (float)widthexcept height:(float)height?

+3
source share
3 answers

. :

- (void)setWidth:(float)width height:(float)height;

setWidth:height:, :

[someObject setWidth:aFloat height:anotherFloat];

+2

. . . ( ), .

+1

Yes, you would be right. This is a missprint. You would call this method the following:

[obj setWidth:100.0f height:200.0f];

Referring to this method in the documentation or to the method callback, it should be marked as setWidth: height: (note the trailing colon). Good luck with the rest of the tutorial.

0
source

Source: https://habr.com/ru/post/1790387/


All Articles