【发布时间】:2012-05-31 15:38:44
【问题描述】:
我在 NSdata 中保存了 CGlayerRef 和 CGcontextRef ,当我让它们覆盖当前的时,我发现只保存了指针,而没有保存数据。 因此,我无法将这些 CGlayerRef 或 CGcontextRef 作为副本。(我都是在 drawRect 中完成的)
为什么?有人说 NSdata 可以存储这些东西,但是 NSvalue 不能,但是,它根本不起作用,即使我使用“复制”,我也没有得到这些数据的副本。
这是我的代码:
-(void)drawRect:(CGRect)rect{
如果 (drawCount==3) {
dataLayer1=[NSData dataWithBytes:& _layerView
长度:sizeof(CGLayerRef)];
[dataLayer1 retain];
}
if (undodo==YES) {
_layerView=*(CGLayerRef*)[dataLayer1 bytes];
}
currentContext = UIGraphicsGetCurrentContext( ....
【问题讨论】:
标签: save nsdata cgcontext cglayer