Abstract for CGMutablePathRef?

I am developing for iphone. I want to create a mutable path through CGPathCreateMutable (), and I want to return it from the function that creates it. I suppose to call CGPathRelease () when I am done with this. But, since I'm coming back, I would like to auto-update it. Since Quartz path is C code (and not like objective C object), can I correctly call it autorelease?

Edit: For others who stumbled upon this question, the following recommendation is that C functions return only base objects. For objective C methods returning basic foundation objects, see Property for returned quartz objects.

+3
source share
1 answer

Correctly. Autorelease pools exist at Foundation level and above (AppKit / UIKit, etc.). They do not exist for CoreFoundation / CoreGraphics objects.

An easy way is to rename your function. If your function is currently called:

CGMutablePathRef myAwesomePath(params...);

Then you should rename it to:

CGMutablePathRef createMyAwesomePath(params...);

so that you can return the object with a saving of +1 by following the Create rule .

+5
source

Source: https://habr.com/ru/post/1745117/


All Articles