Re: Help with NSPointerArray and NSMapTable
Nat! <nat-wUJ93/3i6JkvAvrZIujWRVaTQe2KTcn/@public.gmane.org>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
I coded this up quickly and it seems to work as expected.
Ciao
Nat!
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
static NSUInteger sizeOfRect(const void *item)
{
return( sizeof( NSRect));
}
int main (int argc, const char * argv[])
{
NSPointerArray *p;
NSPointerFunctions *q;
NSRect rect;
NSRect *check;
NSAutoreleasePool *pool;
pool = [NSAutoreleasePool new];
q = [NSPointerFunctions
pointerFunctionsWithOptions:NSPointerFunctionsMallocMemory|
NSPointerFunctionsStructPersonality|NSPointerFunctionsCopyIn];
q.sizeFunction = sizeOfRect;
p = [NSPointerArray pointerArrayWithPointerFunctions:q];
rect = NSMakeRect( 0, 1, 2, 3);
[p addPointer:&rect];
memset( &rect, 0, sizeof( rect));
check = (NSRect *) [p pointerAtIndex:0];
NSLog( @"%f.%f.%f.%f", check->origin.x, check->origin.y, check-
>size.width, check->size.height);
return( 0);
}
------------------------------------------------------
Ignorance more frequently begets confidence than does
knowledge -- Darwin