• 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: Newbie question: error in creating a NSData object using handle (Resource Management)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie question: error in creating a NSData object using handle (Resource Management)


  • Subject: Re: Newbie question: error in creating a NSData object using handle (Resource Management)
  • From: Graham Cox <email@hidden>
  • Date: Fri, 27 Jun 2008 13:14:40 +1000

Just an aside that may or may not be relevant.

In the old days, often variable-length resources and other OS types would have a struct defined for them that used a fixed field size to represent some variable length field in the real resource, for example:

typedef struct
{
    short count;
    long  stuff[1]; // in reality <count> length
}
someResTypeStruct;

This is simply because you can't express variable length structs in C. So using sizeof(someResTypeStruct) == GetHandleSize(anActualResource) very often doesn't work, never has worked, and definitely shouldn't be relied upon. Same goes for allocating memory for such resources, which is why many common types had their own NewXXX function.

That said, you can use C structs in Objective-C normally, just be aware that they might only describe part of the real resource itself (the header, say).



hth,

Graham


On 27 Jun 2008, at 1:00 pm, Tran Kim Bach wrote:

but in reality, in my application, the resource size for this type(PREC) is
various for each resource file(.rsrc).
So, I think the struct caused my problem ( I never thought of it before).
By the way, I have a lot of structs of the same resource type(PREC for
example) written in C,
Is there any way to still take advantage of them in Objective-C?
(I mean if I can use these C structs in Objective-C?, don't have to rewrite
them using Objective-C language).

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Newbie question: error in creating a NSData object using handle (Resource Management) (From: "Tran Kim Bach" <email@hidden>)
 >Re: Newbie question: error in creating a NSData object using handle (Resource Management) (From: Ken Thomases <email@hidden>)
 >Re: Newbie question: error in creating a NSData object using handle (Resource Management) (From: "Tran Kim Bach" <email@hidden>)
 >Re: Newbie question: error in creating a NSData object using handle (Resource Management) (From: Kai <email@hidden>)
 >Re: Newbie question: error in creating a NSData object using handle (Resource Management) (From: "Tran Kim Bach" <email@hidden>)
 >Re: Newbie question: error in creating a NSData object using handle (Resource Management) (From: Ken Thomases <email@hidden>)
 >Re: Newbie question: error in creating a NSData object using handle (Resource Management) (From: "Tran Kim Bach" <email@hidden>)

  • Prev by Date: Re: Newbie question: error in creating a NSData object using handle (Resource Management)
  • Next by Date: Re: NSSpeechSynthesizer and empty strings
  • Previous by thread: Re: Newbie question: error in creating a NSData object using handle (Resource Management)
  • Next by thread: Re: Newbie question: error in creating a NSData object using handle (Resource Management)
  • Index(es):
    • Date
    • Thread