NSString category name collision?
NSString category name collision?
I have defined a category on NSString which includes the following signature.
- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet *) set withString:(NSString *) string
On occasion I encounter the exception listed below where an OSAKit private method calls the same method (and triggers the exception).
Is this a collision between my category method and one presumably/perhaps defined by the OSAKit?
The docs say:
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.
Is this just one of the things we have to put up with as the price for dynamism or can this problem be pre-empted?
I added a name space prefix to my method definition and the exception departed.
*** -[NSCFString rangeOfCharacterFromSet:options:range:]: Range or index out of bounds
-[NSString rangeOfCharacterFromSet:options:range:] (in Foundation) 133
-[NSMutableString(Mugginsoft) replaceCharactersInSet:withString:] (in MGSKosmicTask) (NSString_Mugginsoft.m:220)
-[NSString(Mugginsoft) stringByReplacingCharactersInSet:withString:] (in MGSKosmicTask) (NSString_Mugginsoft.m:203)
[OSADictionary(OSAPrivate) anchorFromName:] (in OSAKit) 53
-[OSADictionary(OSAPrivate) parseData:error:] (in OSAKit) 1180
Regards
Jonathan Mitchell
Developer
http://www.mugginsoft.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden