iOSで描画するためにCgLayersを使用しています。これらのレイヤーを保存して後で取得したいので、利用可能なオプションを知りたいです。NSMutableDictionary を使用しようとしました。以下はコードです。
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGLayerRef testLayer = CGLayerCreateWithContext(UIGraphicsGetCurrentContext(), self.bounds.size, NULL);
CGContextRef context = CGLayerGetContext(testLayer);
CGContextDrawLayerAtPoint(context, CGPointZero, myLayerRef);
// here myLayerRef is my original layer
NSValue *layerCopy = [NSValue valueWithPointer:testLayer];
NSDictionary *lineInfo = [NSDictionary dictionaryWithObjectsAndKeys:layerCopy, @"IMAGE",
nil];
[m_pathArray addObject:lineInfo];
}
-(void) retrieve
{
NSDictionary *lineInfo = [m_pathArray lastObject];
NSValue *val = [lineInfo valueForKey:@"IMAGE"];
CGLayerRef layerRef = (CGLayerRef) [val pointerValue];
CGContextRef context1 = CGLayerGetContext(layerRef);
CGContextDrawLayerAtPoint(context1, CGPointMake(00, 00),layerRef);
[self setNeedsDisplayInRect:self.bounds];
}
よろしくランジット