• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Carbon Handles & NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Carbon Handles & NSData (From: Philip Streck <email@hidden>)

  • Prev by Date: Re: Getting the IP address with remote DO
  • Next by Date: Re: EXC_BAD_ACCESS in an strange place
  • Previous by thread: Carbon Handles & NSData
  • Next by thread: Re: Carbon Handles & NSData
  • Index(es):
    • Date
    • Thread