简体   繁体   中英

Objective-C method calling with multiple arguments

I know the method listed below takes in 2 arguments, card and atTop. Why is atTop repeated twice? I know addCard is the name of the function and this function returns a void where card is a variable of type Card* and I know atTop is of type BOOL, but why is atTop twice?

- (void)addCard: (Card *)card atTop:(BOOL)atTop;

That's because the full name of the method is

- addCard:atTop:

So the first atTop is part of the function name, the second atTop is the name of the parameter (both are equal in this case just by conincidence, they can be different)

It is objective c notation.

(void)addCard: (Card *)card atTop:(BOOL)atTop;

Method name (selector) - "addCard:atTop:"

Parametr 1 type - "Card*" name - "card"

Parametr 2 type - "BOOL" name "atTop"

Return value - "void"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM