I am working with CGLayers, and its blend mode constants, as kCGBlendModeDifference, kCGBlendModeHardLight, kCGBlendModeLuminosity, etc.
I would like to build an array out of these constants and use them by index, in an instruction like
CGContextSetBlendMode(context, [myArrayOfBlendModes objectAtIndex:x]);
but I have two problems here:
1) Objective-C will not allow to build an array using
NSMutableArray * myArrayOfBlendModes = [[[NSMutableArray alloc] initWithObjects:
kCGBlendModeDifference,
kCGBlendModeHardLight,
kCGBlendModeLuminosity,
nil] autorelease];
because these constants are not objects. To make things worst, these constants return CGBlend values…
So, the first point is how to make an array of CGBlends…
2) if this is possible, will
[myArrayOfBlendModes objectAtIndex:x]
return a valid value that can be used on
CGContextSetBlendMode(context, [myArrayOfBlendModes objectAtIndex:x]);
???
and there’s another question here.. an objective-c code used as an argument to a C routine… is it possible?
These are two puzzles I am trying to solve for hours…
thanks for any help
These constants are ints, as far as I can tell. If you really want this kind of functionality you can do something like:
Or, if you really really want to use NSArray’s, you can just throw these into a NSNumber…