CGLayerRef in NSValue - when to call retain() or release()?

混江龙づ霸主 提交于 2019-12-02 08:25:58
Peter Hosey

NSValue doesn't know about Core Foundation types, so it will not retain or release the CGLayer. (The @encoded type string pretty much just tells it how big the value is; it does not tell it anything about memory management.)

You must not release the layer until you are fully done with both the layer and the NSValue.

Or, better yet, just put the CGLayer into the array. All Core Foundation objects are compatible with NSObjects for purposes of memory management (discussed previously), which has the practical effect that you can put CF objects into NSArrays and vice versa. Since CGLayers are CF objects, this means that you can put the CGLayer into the array without boxing it in another object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!