问题
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