Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective C method syntax clarification

I'm new to Objective C and I'm going through a tutorial I found online. The tutorial starts to talk about messaging and argument separation and gives an example:

When there's more than one argument, they're declared within the method name after the colons. Arguments break the name apart in the declaration, just as in a message.

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

I don't think there is suppose to be a colon after width, but I could be wrong. From what I've researched, I believe that it's a typo, but since I am new I just wanted to check.

Is the method just setWidth: height: ? Or is there another argument after the (float)width other than height:(float)height?

like image 437
guy8214 Avatar asked Feb 11 '26 20:02

guy8214


1 Answers

It's a typo. The method signature should read:

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

The method name is setWidth:height: and you would call it like this:

[someObject setWidth:aFloat height:anotherFloat];

like image 167
pwc Avatar answered Feb 14 '26 14:02

pwc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!