我是否需要释放从UIGraphicsGetCurrentContext()返回的上下文?

时间:2010-09-16 10:31:47

标签: iphone cocoa-touch core-graphics

我正在使用CGContextRef

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

我是否需要在上面的电话中拨打CGContextRelease(Context);

1 个答案:

答案 0 :(得分:27)

没有

请参阅The Create Rule vs. The Get Rule

  

创建规则

     

Core Foundation函数具有指示您拥有返回对象的名称:

     

在名称中嵌入“创建”的对象创建函数;   对象复制功能,名称中嵌入了“复制”。

     

[...]

     

获取规则

     

如果您从任何Core Foundation函数接收对象而不是创建或复制功能(例如Get函数) - 您不拥有它[...]

相关问题