CGMutablePathRef to NSMutableArray

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 10:51:49
CGMutablePath path = <... your path ...>;
[mutableArray addObject:(id)path];

CGPath and CGMutablePath are just opaque CFType object types, and those can be added (via casting to id) to any Cocoa container classes that are toll-free bridged to their CoreFoundation counter-parts.

You can wrap CGMutablePathRef to a NSValue and store it in array. Then when needed unwrap it:

//Wrap
NSValue *pathValue = [NSValue valueWithPointer: path];
[array addObject:pathValue];

//Unwrap
NSValue *pathValue = [array objectAtIndex: index];
CGMutablePathRef path = [pathValue pointerValue];

Note that valueWithPointer: method does not affect object's retain count so you must not release your path when adding to array (release it later when it is not needed anymore)

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