Re: Carbon Handles & NSData
Re: Carbon Handles & NSData
- Subject: Re: Carbon Handles & NSData
- From: Pierre-Olivier Latour <email@hidden>
- Date: Sun, 25 Aug 2002 23:33:19 +0200
>
I'm working on a document based application and want to read a OS X icns
>
file through an NSDocument subclass, I would prefer not to have to
>
override writeToFile and readFromFile. So within the
>
loadDataRepresentation method I want to initialize an IconFamilyHandle
>
with the contents of NSData. Here is basically what I'm trying to do,
>
but when I'm calling SetIconFamilyData it returns -50 which is an
>
invalid parameter. I'm new to both Cocoa and Carbon programming and any
>
help would be appreciated.
>
>
OSErr result = 0;
>
Handle dataHandle;
>
>
result = PtrToHand( [data bytes], &dataHandle, [data length] );
>
//error checking...
>
result = SetIconFamilyData( hIconFamily, 'icns', dataHandle );
>
//error checking...
PtrToHand needs to be passed a Carbon Ptr allocated with NewPtr, not an
arbitrary block of memory.
Try this:
Handle h = NewHandle([data length]);
BlockMove([data bytes], *h, [data length]);
SetIconFamilyData( hIconFamily, 'icns', dataHandle );
DisposeHandle(h); (?)
_____________________________________________________________
Pierre-Olivier Latour email@hidden
Lausanne, Switzerland
http://www.pol-online.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.