Reputation: 10839
I'm having issues with this code :
NSString *value = (NSString*)[self.colorsData objectForKey:key];
SEL selector = NSSelectorFromString(value);
BOOL isColorMethod = [[UIColor class] resolveClassMethod:selector];
The String value being passed in as the SEL
selector is @"redColor"
, which as you know is a class method of UIColor
; but the 'isColorMethod'
BOOL
always returns NO.
This code is for a Styling engine I am building.
Upvotes: 0
Views: 508
Reputation: 9091
You have used the wrong method. If you want to know whether something is a string method you should use respondsToSelector:
and instancesRespondToSelector:
.
Upvotes: 1
Reputation: 10839
Ok, I have a fix ... you can do this instead, despite respondsToSelector
not showing as an available class method :
BOOL isColorMethod = [[UIColor class] respondsToSelector:selector];
I'm not sure why resolveClassMethod
doesn't work when respondsToSelector
does, however.
So, although I am answering my own question I would be interested in knowing what is happening here.
Upvotes: 0