我不知道这种语法是有效的。
+ (void) methodName:(TypeObject *)typeObject1:(TypeObject *)typeObject2;
然后如下调用:
[object methodName:obj1:obj2];
我发现它很丑陋而令人不安,但它会建立。
有人可以指点我的参考资料,解释为什么这是有效的。
FWIW这个来自的代码库(继承),充斥着草率,懒惰的东西,几十个拼写错误,看起来它是由某人无需再次阅读的格式化。 (再次感谢uncrustify。)
答案 0 :(得分:8)
这是well-kown and documented feature (pdf, p. 14)
原则上,Rectangle类可以改为实现
setOrigin::
第二个参数没有标签的方法,将被调用 如下:
[myRectangle setOrigin:30.0 :50.0]; // This is a bad example of multiple parameters
但是苹果discourage everbody of using parameter passing without keyword:
在所有参数之前使用关键字
- (void)sendAction:(SEL)aSelector to:(id)anObject forAllCells:(BOOL)flag;
- >右。
- (void)sendAction:(SEL)aSelector :(id)anObject :(BOOL)flag;
- >错。
为什么它被Objective-C的创造者所允许,我不知道。也许它与Smalltalk遗产有关。