Hello, i have a question about the CGLayerRef "elements" ( because they are not object !)
In my app, i want to store a list of CGLayerRef created from bitmaps, for obtain a good framerate on my DrawRect.
how can i store and read the CGLayerRef in this code ?
This is the code for store in the NSMutableArray
CGLayerRef imageLayer;
// create my layer...
// init my NSMutableArray
if (layerTable == nil) {
layerTable = [[NSMutableArray alloc] init];
}
// and store my CGCLayer in this array with NSValue
[layerTable addObject:[[NSValue alloc] initWithBytes:imageLayer objCType:"CGLayerRef"]];
Now the code for DrawRect in my view :
"actualIdp" is a int for identify the layer to draw.
-(void)drawInContext:(CGContextRef)context{
// other code...
// here I want to read my CGLayerRef
//test with NSValue, but i don't know NSValue
NSValue *val = [layerTable objectAtIndex:actualIdp];
CGLayerRef layerToShow;
[val getValue:layerToShow]; // maybe an error
CGContextDrawLayerInRect(context, imageRect, layerToShow );
}
Here, the code for change my id :
-(void)showThisId:(int)idp{
actualIdp = idp;
[self setNeedsDisplay];
};