iabudiab / HTMLKit

An Objective-C framework for your everyday HTML needs.
MIT License
239 stars 27 forks source link

Collision with Category Names #35

Closed jerelevine closed 5 years ago

jerelevine commented 5 years ago

The NSString+HTMLKit.h and NSCharacterSet+HTMLKit.h categories contain generic named category methods. They are causing collisions with other methods I've already been using. It would be great if you could prefix the methods to reduce potential collisions. Perhaps the prefix could be "html_" or something similar. Thanks!

iabudiab commented 5 years ago

@jerelevine Hey there, do you mean all the category methods or just the generic ones?

Looking at the NSString Category, I could hide the first three methods completely, since these are too general. The other three could be prefixed.

@interface NSString (HTMLKit)
// Hide
- (BOOL)isEqualToStringIgnoringCase:(NSString *)aString;
- (BOOL)isEqualToAny:(NSString *)first, ... NS_REQUIRES_NIL_TERMINATION;
- (BOOL)hasPrefixIgnoringCase:(NSString *)aString;

// Prefix
- (BOOL)isHTMLWhitespaceString;
- (NSUInteger)leadingHTMLWhitespaceLength;
- (NSString *)stringByEscapingForHTML;
@end

The NSCharacterSet category could also be either completely hidden or prefixed.

@interface NSCharacterSet (HTMLKit)
+ (instancetype)HTMLWhitespaceCharacterSet;
+ (instancetype)HTMLHexNumberCharacterSet;
+ (instancetype)CSSNthExpressionCharacterSet;
@end
jerelevine commented 5 years ago

Thanks for responding! Yeah I think like your suggestion. Seems like a perfect solution to me. I don't use the NSCharacterSet category methods but I could see others using them. Probably worth keeping them visible but prefixed.

iabudiab commented 5 years ago

Released in Version 3.0.0