Just use NSPointerArray:
@implementation NSPointerFunctions (Additions)
static NSUInteger _PointerFunctionsCGPointStructSize(const void *item)
{
return sizeof(CGPoint);
}
+ (NSPointerFunctions *)pointerFunctionsForCGPoint;
{
NSPointerFunctions *aPointerFunctions = [NSPointerFunctions
pointerFunctionsWithOptions:(NSPointerFunctionsStructPersonality|NSPointerFunctionsMallocMemory|NSPointerFunctionsCopyIn)];
[aPointerFunctions setSizeFunction:&_PointerFunctionsCGPointStructSize];
return aPointerFunctions;
}
@end
@implementation NSPointerArray (Additions)
+ (id)pointPointerArray;
{
return [[[self alloc] initWithPointerFunctions:[NSPointerFunctions
pointerFunctionsForCGPoint]] autorelease];
}
- (CGPoint)pointAtIndex:(NSUInteger)theIndex;
{
return *(CGPoint *)[self pointerAtIndex:theIndex];
}
- (void)addPoint:(CGPoint)thePoint;
{
[self addPointer:&thePoint];
}
@end
Jonathan
http://madebysofa.com
On 27 Nov 2009, at 21: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 result is for
> the points) and it just seems cleaner and more efficient if I can stay
> with that instead of converting between point arrays and mutable
> arrays.
> _______________________________________________
>
> Cocoa-dev mailing list ([email protected])
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/j.p.dann%40gmail.com
>
> This email sent to [email protected]
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]