Re:Show HN: NSString + Ruby
by thingsdoer on Thursday October 10, 2013 @05:28PM
(#6530158)
I'd correct the category. Also, NSString is not going to change. If it does, it will be rewritten extensively, most probably obsoleting this category.
Re:Show HN: NSString + Ruby
by chrisdevereux on Thursday October 10, 2013 @05:38PM
(#6530201)
Methods are often added to core classes like NSString. For example, in iOS 6:
https://developer.apple.com/library/ios/releasenotes/General...
And you changing the category won't help the versions already out in the wild. Hopefully, automatic updates will mitigate this to some degree but not everyone will turn them on.
There are workarounds (like prefixing methods with a pseudo-namespace), but they're all a bit ugly. Might be worth considering though.
Re:Show HN: NSString + Ruby
by thingsdoer on Thursday October 10, 2013 @05:37PM
(#6530197)
Actually, I might add some protection around this specific case.
If a future version of iOS adds an -sum method, for example, you'd better hope it has the exact same semantics as yours, otherwise if the system calls -sum expecting its implementation to be used, bad things (or worse, bad things with no apparent cause) will happen when your implementation is used instead.