iPhone-将CGPath添加到NSMutableArray ...如何? [英] iPhone - adding a CGPath to a NSMutableArray... how?
本文介绍了iPhone-将CGPath添加到NSMutableArray ...如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我需要向数组中添加整数时
When I need to add a integer to an array I use
[myArray addObject:[NSNumber numberWithInt:myInt]];
但是CGPaths呢?如何将它们添加到阵列中?
but what about CGPaths? How do I add them to the array?
我需要类似的东西
"[NSValue valueWithCGPath:myPath]"... ???!!!
有什么线索吗?谢谢
推荐答案
可以定位到iOS 3.2或更高版本的最简单方法是将 CGPathRef
包装在 UIBezierPath
中:
The easiest way if you can target iOS 3.2 or higher is to wrap the CGPathRef
in a UIBezierPath
:
[myArray addObject:[UIBezierPath bezierPathWithCGPath:myPath]];
如果您需要支持早期的iOS版本,则可以使用 CFArray
代替 NSArray
,因为 CGPath
源自 CFType
.
If you need to support earlier iOS versions, you can use a CFArray
instead of NSArray
because CGPath
derives from CFType
.
这篇关于iPhone-将CGPath添加到NSMutableArray ...如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文