@interface NSArray (Populate)
-(NSArray *) populateArray;
@end
If there is another category (from another module or library), use a method with the same name to extend NSArray, how to detect the situation?
For example, if there is NSArray Fill.h:
@interface NSArray (Fill)
-(NSArray *) populateArray;
@end
As far as I know, the runtime engine will silently select one of the versions without any crashes?
quoting The Objective-C Programming Language file,
A category cannot reliably override methods declared in another category of the same class.
This issue is of particular significance since many of the Cocoa classes are implemented using categories. A framework-defined method you try to override may itself have been implemented in a category, and so which implementation takes precedence is not defined.
I want to use the category NSArray Populate.h to extend a class: < p>
@interface NSArray (Populate)
-(NSArray *) populateArray;
@end
If there is another Category (from another module or library), use a method with the same name to extend NSArray, how to detect the situation?
For example, if there is NSArray Fill.h:
@interface NSArray (Fill)
-(NSArray *) populateArray;
@end
As far as I know, the runtime engine will silently select one of the versions without any crashes?
You cannot detect this situation, nor can you determine which implementation of -populateArray takes precedence. For this reason, some developers prefer the category method Add the name before
quote The Objective-C Programming Language file,
A category cannot reliably override methods declared in another category of the same class.
This issue is of particular significance since many of the Cocoa classes are implemented using categories. A framework-defined method you try to override may itself have been implemented in a category, and so which implementation takes precedence is not defined.