Re: dynamic NSPointArray allocation
Re: dynamic NSPointArray allocation
- Subject: Re: dynamic NSPointArray allocation
- From: Shane <email@hidden>
- Date: Fri, 27 Nov 2009 16:58:27 -0600
>
> The easiest way (and Objective-C-ish way) is to use a NSMutableData object with the NSPointArray as its data. Whenever you want to add points, just resize the NSMutableData object to 'sizeof (NSPoint)' * total number of points, and use '(NSPointArray) [data mutableBytes]' as a pointer to the start of the array.
>
I think I'm understanding this in part ...
// *.h
NSMutableData *pointData;
NSPointArray *points;
// *.m
pointData = [[NSMutableData alloc] init];
...
NSPoint point = NSMakePoint([iters floatValue], [mse floatValue]);
// not sure how to get an NSPoint into NSMutableData?
// here I resize NSMutableData, but this will always only be
// increasing the length by 1.
[pointData increaseLenghtBy:sizeof(NSPoint)];
// and here I assign the data to NSPointArray
points = (NSPoint *) [pointData bytes];
And from here I can pass this NSPointArray around till I get to the
point where I will use this data for my NSBezierPath. Will
NSBezierPath (which takes an NSPointArray) be able to properly read
from 'points' by doing the above?
Am I even going about this correctly?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden