Re: Newbie question: error in creating a NSData object using handle (Resource Management)
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: Kai <email@hidden>
- Date: Fri, 27 Jun 2008 09:00:14 +0200
On 27.6.2008, at 05:00, Tran Kim Bach wrote:
Wow, thanks Ken a lot.
About the endian issues, I have a compatible swap function to
convert data to Big-endian (and vice verse).
Then, I will correct big-endian issues.
I may know where the problem is.
When I read to your suggestion,
On Fri, Jun 27, 2008 at 6:11 AM, Ken Thomases <email@hidden>
wrote:
data = [NSData dataWithBytes:*dataHandle length:sizeLong ];
resID = [NSNumber numberWithShort:resIDShort];
if((type2 =='PREC')&&([resID intValue]== 302))
{
struct PGControlRes pgControlRes;
memcpy(&pgControlRes,[data bytes], [data length]);
Have you tested that the resource size is the same as the structure
size?
I found out something.
Actually, I'm just trying to make a prototype in one fixed size of
the same resource type.
I used to test on the same resource files with this fixed resource
structure.
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?
Absolutely. Objective-C is a superset of C, so you can use all C you’d
ever like to use.
Code of you like
NSNumber* resID = [NSNumber numberWithShort:resIDShort];
and later
[resID intValue]
is pretty unnecessary - unless you are going to use resID with some
Cocoa message which expects an NSNumber.
Another tip: Handle locking (HLockHi, HUnlock) is a no op under Mac OS
X and can be skipped.
Best
Kai
(I mean if I can use these C structs in Objective-C?, don't have to
rewrite them using Objective-C language).
Thank you for your supports.
---(Bachtk
_______________________________________________
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