iPhone - 编码和解码NSValue

Spa*_*Dog 6 iphone cocoa quartz-graphics cglayer

所以我在这里读到我可以用CGLayerRef编译CGLayerRef到NSValue

NSValue *myCopy = [[NSValue alloc] initWithBytes:&myLayer objCType:@encode(CGLayerRef)]; 
Run Code Online (Sandbox Code Playgroud)

但是如何从myCopy重新创建CGLayerRef?

谢谢

小智 6

这应该工作:

CGLayerRef giveMeBackTheLayer;
[myCopy getValue:&giveMeBackTheLayer];
Run Code Online (Sandbox Code Playgroud)