Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c CGMutablePathRef到NSMutableArray_Objective C_Nsmutablearray - Fatal编程技术网

Objective c CGMutablePathRef到NSMutableArray

Objective c CGMutablePathRef到NSMutableArray,objective-c,nsmutablearray,Objective C,Nsmutablearray,如何将CGMutablePathRef添加到NSMutableArray?您可以将CGMutablePathRef包装到NSValue并存储在数组中。然后在需要时将其展开: //Wrap NSValue *pathValue = [NSValue valueWithPointer: path]; [array addObject:pathValue]; //Unwrap NSValue *pathValue = [array objectAtIndex: index]; CGMutablePa

如何将CGMutablePathRef添加到NSMutableArray?

您可以将CGMutablePathRef包装到NSValue并存储在数组中。然后在需要时将其展开:

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

//Unwrap
NSValue *pathValue = [array objectAtIndex: index];
CGMutablePathRef path = [pathValue pointerValue];
请注意,
valueWithPointer:
方法不会影响对象的保留计数,因此在添加到数组时不能释放路径(以后不再需要时释放路径)

CGMutablePath=;
[mutableArray addObject:(id)路径];
CGPath
CGMutablePath
只是不透明的CFType对象类型,可以(通过强制转换到
id
)添加到任何免费桥接到CoreFoundation计数器部件的Cocoa容器类中

CGMutablePath path = <... your path ...>;
[mutableArray addObject:(id)path];