hi,the code is
NSString *st = [[UIColor greenColor] description];
it gives wrong output. i want to get the Result , st must be @"greenColor" as a NSString any help please?
hi,the code is
NSString *st = [[UIColor greenColor] description];
it gives wrong output. i want to get the Result , st must be @"greenColor" as a NSString any help please?
greenColor is just the name of a class method on UIColor. Once the UIColor is constructed it doesn't know it's a greenColor - it just knows that it has colour values that happen to make green.
So I'd suggest one of two things.
UIColor that intercepts description and compares the colour values against the set of colour constructors and return the appropriate string.UIColor and store a colour name string. Supply a description method that just returns that string.I suspect (2) is simpler but requires that you are able to use your subclassed version instead of UIColor.