tags:

views:

1990

answers:

2

in CABasicAnimation.fromValue i want to convert a CGPoint to a "class" so i used NSValue valueWithPoint but in device mode or simulator one is not working... need to use NSMakePoint or CGPointMake if in device or simulator...

A: 

Don't think of it as "converting" your point-- NSValue is a wrapper class that holds primitive structs like NSPoint. Anyway, here's the function you need. It's part of Cocoa, but not Cocoa Touch. You can add the entire function to your project, or just do the same conversion wherever you need it.

NSPoint NSPointFromCGPoint(CGPoint cgpoint) {
   return (*(NSPoint *)&(cgpoint));
}
Marc Charbonneau
Can you please explain the syntax used in your reply? Looks useful.
Dimitris
+7  A: 

There is a UIKit additon to NSValue that defines a function

+ (NSValue *)valueWithCGPoint:(CGPoint)point

See iPhone doc

ashcatch