Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - adding a CGPath to a NSMutableArray... how?

Tags:

iphone

When I need to add a integer to an array I use

[myArray addObject:[NSNumber numberWithInt:myInt]];

but what about CGPaths? How do I add them to the array?

I need something like

"[NSValue valueWithCGPath:myPath]"... ???!!!

any clues? thanks

like image 926
Duck Avatar asked Jun 19 '11 17:06

Duck


1 Answers

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]];

If you need to support earlier iOS versions, you can use a CFArray instead of NSArray because CGPath derives from CFType.

like image 158
Daniel Dickison Avatar answered Sep 22 '22 14:09

Daniel Dickison