Re: store the NSPoint in an dictionary
Re: store the NSPoint in an dictionary
- Subject: Re: store the NSPoint in an dictionary
- From: Greg Titus <email@hidden>
- Date: Thu, 28 Jun 2001 23:47:32 -0700
On Thursday, June 28, 2001, at 11:12 PM, Annie Felix wrote:
Hi
My program draws a circle on mouse click.
On Mouse drag it draws a line.
On mouse release it draws another circle.
Now I have got two points, which I store in NSPoint.
Now I want to store these points in an dictionary for reference.
How should I do it.
Hi Annie,
Look at NSGeometry.h's extensions to NSValue which includes:
+ (NSValue *)valueWithPoint:(NSPoint)point;
+ (NSValue *)valueWithSize:(NSSize)size;
+ (NSValue *)valueWithRect:(NSRect)rect;
- (NSPoint)pointValue;
- (NSSize)sizeValue;
- (NSRect)rectValue;
So you can create an NSValue object with the +valueWithPoint: method,
store the value in your dictionary, then retrieve the point from it by
sending the value object a -pointValue message.
Hope this helps,
--Greg