Do I need to release the context returned from UIGraphicsGetCurrentContext()?

落花浮王杯 提交于 2019-12-09 14:04:13

问题


I am using CGContextRef.

UIGraphicsBeginImageContext(self.drawImage.frame.size);
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context,0.0f,0.0f,0.0f,1.0f);
UIGraphicsEndImageContext();
CGContextRelease(context);

Do I need to call CGContextRelease(Context); in the above one.


回答1:


No.

See The Create Rule vs. The Get Rule:

The Create Rule

Core Foundation functions have names that indicate when you own a returned object:

Object-creation functions that have “Create” embedded in the name; Object-duplication functions that have “Copy” embedded in the name.

[...]

The Get Rule

If you receive an object from any Core Foundation function other than a creation or copy function—such as a Get function—you do not own it [...]



来源:https://stackoverflow.com/questions/3725786/do-i-need-to-release-the-context-returned-from-uigraphicsgetcurrentcontext

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