Objective c CGMutablePathRef到NSMutableArray
如何将CGMutablePathRef添加到NSMutableArray?您可以将CGMutablePathRef包装到NSValue并存储在数组中。然后在需要时将其展开: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
//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];