Hi,

"I GOT AN ERROR HERE" may be a little too unspecific. Perhaps you can elaborate: crash, exception, nil return, Console entry, what else?

That said, you should use GetHandleSize (dataHandle) instead of GetResourceSizeOnDisk(dataHandle). GetResourceSizeOnDisk() can return values which are too large (see documentation).

Ah, and I just see that you combinded CountResources with Get1IndResource, that’s probably wrong. You should use CountResources with GetIndResource or Count1Resources with Get1IndResource.

Neither of this directly explains the difference between using NSData and the direct copy. But since you potentially access non existing bytes or data, that may be coincidence.

Best
Kai

Hi folks,I'm a newbie to Cocoa.
Recently, I'm working on a project relating to Resource Management.
In my project, there's a part that I'm reading through the resources in a
resource file.
I'm using:
int count = CountResources( typeName );
to get all resource that has the type "typeName", then loop through this
resource list to take resource data out.

for (n = 1; n <= count; n++)
{
  Handle dataHandle = Get1IndResource( type1, n);
  ....
  NSData *data = [NSData dataWithBytes: *dataHandle length:
GetResourceSizeOnDisk(dataHandle)];  // I GOT AN ERROR HERE
  //using data
  struct A_STRUCT aStruct;

  memcpy(& aStruct,[data bytes], [data length]);
}
After several times looping through the list, I got an error in the line
above.
But if I use data directly, like the following code, there is no error
occurred.
 memcpy(&pgControlRes,*dataHandle, GetResourceSizeOnDisk(dataHandle));
Any suggestions for my problem.
I highly appreciate all your helps.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/kai%40granus.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to