views:

477

answers:

3

Probably I could create a class that holds an CGPoint as instance variable, like a wrapper. Does that make sense? I feel uncomfortable with that, though. I hope there is an better solution.

How about any self-created scalar type? Like MyCoolScalarType?

+1  A: 

NSValue

Remus Rusanu
A: 

You can box a CGPoint value into an NSValue object. It is documented in NSValue UIKit Additions Reference.

Chris Lundie
+5  A: 

Make it an object. You could try this:

CGPoint point = CGPointMake(1.f,1.f);

[NSValue valueWithCGPoint:point];

This goes for pretty much every scalar you want to put in an NSArray:

CGFloat foo = 1.f;

[NSNumber numberWithFloat:foo];
Kriem
How about own defined scalar types? like MyCoolScalar?
Thanks
From the NSValue documentation (which you should look through): "An NSValue object is a simple container for a single C or Objective-C data item. It can hold any of the scalar types such as int, float, and char, as well as pointers, structures, and object ids."
Alex Reynolds
Alex beat me to it. :) But he's right. So, basically you're still wrapping. But it's a very good and much practiced method.
Kriem