根据 Apple果目标C文件,粗略相关部分:
www.un.org/Depts/DGACM/index_spanish.htm 方法回归和参数类型
The messaging routine has access to method implementations only through selectors, so it treats all methods with the same selector alike. It discovers the return type of a method, and the data types of its parameters, from the selector. Therefore, except for messages sent to statically typed receivers, dynamic binding requires all implementations of identically named methods to have the same return type and the same parameter types. (Statically typed receivers are an exception to this rule because the compiler can learn about the method implementation from the class type.)
Although identically named class methods and instance methods are represented by the same selector, they can have different parameter types and return types.
我已经读过这个栏目,但我看不出似乎有矛盾之处。 首先,它指出,所有采用相同名称的方法,都必须具有相同的返回类型和参数类型,因为动态具有约束力。
既然所有方法都与相同的选择一样对待,这是否意味着,无论我拥有多少不同的物体,如果他们都有一种EatCake(EatCake)方法,那么他们都会分享同样的选择。 如果是的话,那么他们为什么有同样的参数和返回类型?
然后,在下一个部分,它说,虽然他们是由同一选择人代表的,但他们可以有不同的参数类型和返回类型。 因此,我现在完全混淆不清,我认为刚才所说的情况并非如此。
我并不期望这是错误的,我希望我根本不理解这两个发言之间的区别。
谁能向我表明这一点?