PDA

View Full Version : UIColor from string




sujithkrishnan
Jul 28, 2008, 04:48 AM
Hi all..

Is there any method which will give me a UIColor, provided i gave a valid colorName as String ??

I am having aPlist which will tells the app to set which backColor, textColor etc.... etc...

My app will read that and set the color...

Instead of a longer " Switch and case" i am searching for a method which will return the Color.



robbieduncan
Jul 28, 2008, 05:02 AM
If it was an instance method then you could get a selector and use the normal method (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/performSelector:) to perform the selector.

I'm not clear if you can do this with class methods or not. You could try something like:


[UIColor performSelector:NSSelectorFromString(@"blackColor")];


and see if it works (I'm not on a Mac to try it myself...)