I wrote a utility class with idiomatic Obj-C color methods like the one you mentioned and more. I hate to plug it, but I'm fairly proud of it. It also generates color schemes when you throw a UIColor object at it, and includes 100 different UIColor generics like [UIColor seafoamColor].
One thing that irks me is that the author doesn't stick to ObjC naming conventions.
Take for example the capitalize methods. In ruby, you have "capitalize" and "capitalize!" to distinguish the immutable and mutable versions. To make this distinction in ObjC, you generally use nouns vs. verbs. So for the equivalent of ruby's "capitalize", you'd use "capitalizedString" (which is in fact provided by NSString). But the mutable version, the equivalent of ruby's "capitalize" should simply be "capitalize", not "capitalizedStringInPlace".
They look like convenient additions... but I'd be reluctant to add so many category methods onto a Foundation class. Especially for un-prefixed methods.
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.
There are already a lot of Ruby categories out there. ObjectiveSugar covers a lot of bases. I personally wouldn't import more Ruby categories. The NSString API is a weak point of Cocoa, IMO, but in general I wouldn't like to see a large amount of unique, dependent, astonishing code.
I have to add the obligatory pitch for just using RubyMotion. I use it/love it, and def recommend it for those that have become a bit annoyed with the verbose-ness of obj-c.
I love the idea of RM and would like to give it a try, but I keep hearing murmurs about memory management issues and other little glitches that crop up from time to time. I also hear that these kinds of problems get fixed very quickly, but the idea of being stuck even for a short time while waiting for a proprietary abstraction to be patched up makes me a bit hesitant to reach for it for a serious app. Are these concerns overblown?
Good, I was worried people could actually be able to correctly manipulate text through NSString, that fixes it as it's impossible to not break text when using Ruby strings.
[+] [-] dennis_vartan|12 years ago|reply
For example, I ended up putting together some defines like this after building a bunch of UI programmatically.
RGB(255, 104, 0) may be a bit too C-ish, but it sure beats the long form. Have similar GRAY(x) and GRAYA(x) defines for producing grayscale colors.Definitely interested to see more projects along these lines.
[+] [-] wrl|12 years ago|reply
[+] [-] cheesylard|12 years ago|reply
[+] [-] bennyg|12 years ago|reply
https://github.com/bennyguitar/Colours-for-iOS
[+] [-] numo16|12 years ago|reply
[0]: https://gist.github.com/numo16/3407652
[+] [-] stefan_kendall|12 years ago|reply
SO handy.
[+] [-] jakobe|12 years ago|reply
Take for example the capitalize methods. In ruby, you have "capitalize" and "capitalize!" to distinguish the immutable and mutable versions. To make this distinction in ObjC, you generally use nouns vs. verbs. So for the equivalent of ruby's "capitalize", you'd use "capitalizedString" (which is in fact provided by NSString). But the mutable version, the equivalent of ruby's "capitalize" should simply be "capitalize", not "capitalizedStringInPlace".
[+] [-] thingsdoer|12 years ago|reply
The reasoning for this is for consistency, while still maintaining autocomplete proximity.
[+] [-] khangtoh|12 years ago|reply
[+] [-] chrisdevereux|12 years ago|reply
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.
[+] [-] thingsdoer|12 years ago|reply
[+] [-] jph|12 years ago|reply
I'll donate $100 to you if you want to continue with NS+Ruby classes.
[+] [-] thingsdoer|12 years ago|reply
[+] [-] w0rdson|12 years ago|reply
[+] [-] danenania|12 years ago|reply
[+] [-] andrewgross|12 years ago|reply
https://github.com/nsantorello/nsarray-extensions
[+] [-] sarreph|12 years ago|reply
[+] [-] masklinn|12 years ago|reply
[+] [-] thingsdoer|12 years ago|reply
[+] [-] pdenya|12 years ago|reply
[+] [-] fleitz|12 years ago|reply
[+] [-] hamxiaoz|12 years ago|reply
[+] [-] fleitz|12 years ago|reply
https://developer.apple.com/library/ios/documentation/Cocoa/...
[+] [-] YoyosForUs|12 years ago|reply
[+] [-] mamcx|12 years ago|reply
[+] [-] thingsdoer|12 years ago|reply
[+] [-] misiti3780|12 years ago|reply