I need to return a specific UIColor for a given index.
I am trying to basically store the UIColors as NSArrays
TypeColors = [[NSDictionary alloc] initWithObjectsAndKeys:
@”1″, [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.5],[NSNumber numberWithFloat:0.5],[NSNumber
numberWithFloat:0.5],[NSNumber numberWithFloat:1.0], nil],@”5″, [NSArray arrayWithObjects:[NSNumber numberWithFloat:1.0],[NSNumber
numberWithFloat:0.5],[NSNumber numberWithFloat:0.1],[NSNumber
numberWithFloat:1.0], nil]
, nil]; //nil to signify end of objects and keys.
And here I want to retrieve the UIColor back from that dictionary:
a = 5;
NSArray* colorArray = [TypeColors objectForKey:a];
UIColor* color = [UIColor colorWithRed:[colorArray objectAtIndex:0]
green:[colorArray objectAtIndex:1] blue:[colorArray objectAtIndex:2]
alpha:[colorArray objectAtIndex:3]];
It always returns me a zero, anyone knows why?
Thanks!
Change it to
The parameter to be sent there is cgfloat and not NSNumber