A superclass defines a method, and a subclass overrides this method. The only difference is that the subclass adds the parameter to the block, which itself is the parameter of the method.
Imagine that I have a class Collectionand a class of descendants Listthat define, among other methods, an enumeration method in style NSArray.
Collection
List
NSArray
@interface Collection : NSObject - (void)enumerateObjectsUsingBlock: (void (^)(id obj))block; @end @interface List : Collection - (void)enumerateObjectsUsingBlock: (void (^)(id obj, int index))block; @end
Does it work (on all platforms) and is it up to standard?
I would suggest that this would work, since the list of parameters in the superclass method would not be affected, while users of the subclass method would know (not necessarily with some type) an additional parameter.
; , .
:
, . Objective-C - ( instancetype). , .
instancetype
, , , , , (a), (a, b) , (a,b.c), (a,b,c,d) .., . fun(a,b,c,d), fun fun(a) , , .
(a)
, (a,b.c)
(a,b,c,d)
fun(a,b,c,d)
fun
fun(a)