Re: dynamic NSPointArray allocation

2009-12-01 Thread Andrew Farmer
On 1 Dec 2009, at 05:27, Jonathan Dann wrote: Just use NSPointerArray... Just as is the case with an array of NSValue objects, NSPointerArray doesn't help here -- it makes no guarantees about how the objects will be arranged in memory, and NSBezierPath needs them to be

Re: dynamic NSPointArray allocation

2009-11-28 Thread Quincey Morris
On Nov 27, 2009, at 14:58, Shane wrote: I think I'm understanding this in part ... // *.h NSMutableData *pointData; NSPointArray *points; // *.m pointData = [[NSMutableData alloc] init]; ... NSPoint point = NSMakePoint([iters floatValue], [mse

Re: dynamic NSPointArray allocation

2009-11-28 Thread Henry McGilton (Boulevardier)
On Nov 28, 2009, at 2:50 PM, Quincey Morris wrote: On Nov 27, 2009, at 14:58, Shane wrote: I think I'm understanding this in part ... // *.h NSMutableData *pointData; NSPointArray *points; // *.m pointData = [[NSMutableData alloc] init]; ... NSPoint

Re: dynamic NSPointArray allocation

2009-11-28 Thread Andrew Farmer
On 28 Nov 2009, at 15:12, Henry McGilton (Boulevardier) wrote: Another possible approach is simply use a NSMutableArray full of NSValue objects that contain the NSPoint structures . . . I don't believe that'll work - storing everything in NSValue objects will end up scattering the actual

dynamic NSPointArray allocation

2009-11-27 Thread Shane
I don't know how large my NSPointArray size needs to be so I'd like to know how I would dynamically allocate NSPoints to populate an NSPointArray? I think I can do it with NSMutableArray, but NSBezierPath takes an NSPointArray (which is what my end result is for the points) and it just seems

Re: dynamic NSPointArray allocation

2009-11-27 Thread Quincey Morris
On Nov 27, 2009, at 12:46, Shane wrote: I don't know how large my NSPointArray size needs to be so I'd like to know how I would dynamically allocate NSPoints to populate an NSPointArray? I think I can do it with NSMutableArray, but NSBezierPath takes an NSPointArray (which is what my end

Re: dynamic NSPointArray allocation

2009-11-27 Thread Shane
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

Re: dynamic NSPointArray allocation

2009-11-27 Thread Graham Cox
On 28/11/2009, at 7:46 AM, Shane wrote: I don't know how large my NSPointArray size needs to be so I'd like to know how I would dynamically allocate NSPoints to populate an NSPointArray? I think I can do it with NSMutableArray, but NSBezierPath takes an NSPointArray (which is what my end

Re: dynamic NSPointArray allocation

2009-11-27 Thread Shane
Why not just accumulate the points directly into NSBezierPath? It can be thought of as an array of points in a sense. Unless there's a compelling need to have the points themselves available in addition to the bezier path, just cut out the middle man (and it's not difficult to retrieve the

Re: dynamic NSPointArray allocation

2009-11-27 Thread Graham Cox
On 28/11/2009, at 10:37 AM, Shane wrote: Why not just accumulate the points directly into NSBezierPath? It can be thought of as an array of points in a sense. Unless there's a compelling need to have the points themselves available in addition to the bezier path, just cut out the middle