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

2008-06-27 Thread Kai
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

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

2008-06-26 Thread Graham Cox
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;

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

2008-06-26 Thread Tran Kim Bach
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 PROTECTED]

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

2008-06-26 Thread Ken Thomases
On Jun 25, 2008, at 9:49 PM, Tran Kim Bach wrote: On Wed, Jun 25, 2008 at 3:36 PM, Ken Thomases <[EMAIL PROTECTED]> wrote Also, in the pseudo-code you provide, the NSData objects will accumulate in the autorelease pool until some point after your "for" loop. You can try using an autorel

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

2008-06-26 Thread Tran Kim Bach
> > > if((type2 =='PREC')&&([resID intValue]== 302)) > There is a typo in the above code line:It should be: if((resType1 =='PREC')&&([resID intValue]== 302)) > Regards, Bachtk ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post

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

2008-06-25 Thread Tran Kim Bach
Thanks everybody for your kind helps. I'm so happy that all of you welcome me warmly here. On Wed, Jun 25, 2008 at 3:36 PM, Ken Thomases <[EMAIL PROTECTED]> wrote > > > Also, in the pseudo-code you provide, the NSData objects will accumulate in > the autorelease pool until some point after your "fo

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

2008-06-25 Thread Jens Alfke
Handle dataHandle = Get1IndResource( type1, n); I hope you checked that dataHandle!=NULL and *dataHandle!=NULL. struct A_STRUCT aStruct; memcpy(& aStruct,[data bytes], [data length]); This is dangerous — if [data length] is larger than sizeof(aStruct), you've just clobbered yo

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

2008-06-25 Thread Gary L. Wade
1. Have you set the resource file you're iterating over as the current resource file (UseResFile)? Make sure you save off the current resource file (CurResFile) before you do that so you can reset it once you close it. The Resource Manager is not good at keeping track of state in the way you m

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

2008-06-25 Thread I. Savant
> PS: In case you have more questions about old-style resource access, > you'd better take them to Apples Carbon list. People there are > probably more understanding about the need to use time proven but no > longer fancy APIs. ;-) Not that you're bitter, though ... ;-) -- I.S.

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

2008-06-25 Thread Kai
On 25.6.2008, at 10:42, Tran Kim Bach wrote: Thanks Ken and Kai for your very very quick responses This is my first post in the list, I'm sorry for not clarifying my problem. Actually, the program stopped at the mentioned line. In console, it said something like: objc[2144]: FREED(id): mess

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

2008-06-25 Thread Andrew Farmer
On 25 Jun 08, at 06:43, Hamish Allan wrote: Someone who knows more about these things than I do may be able to point you in the direction of a more modern way of accessing resources :) There is, in fact, no "more modern way" of accessing resources. The preferred alternative is to use indivi

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

2008-06-25 Thread Hamish Allan
On Wed, Jun 25, 2008 at 2:08 PM, Kyle Sluder <[EMAIL PROTECTED]> wrote: > On Wed, Jun 25, 2008 at 4:42 AM, Tran Kim Bach <[EMAIL PROTECTED]> wrote: > >> But I checked the exe file and it's absolutely there(in the bundle). > > What is this "exe file" nonsense? I don't have any files with the > ext

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

2008-06-25 Thread Kyle Sluder
On Wed, Jun 25, 2008 at 4:42 AM, Tran Kim Bach <[EMAIL PROTECTED]> wrote: > Actually, the program stopped at the mentioned line. > In console, it said something like: > > *objc[2144]: FREED(id): message release sent to freed object=0x17d1d0* > > This GDB was configured as "i386-apple-darwin" > (Err

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

2008-06-25 Thread Tran Kim Bach
Thanks Ken and Kai for your very very quick responsesThis is my first post in the list, I'm sorry for not clarifying my problem. Actually, the program stopped at the mentioned line. In console, it said something like: *objc[2144]: FREED(id): message release sent to freed object=0x17d1d0* This GD

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

2008-06-24 Thread Ken Thomases
On Jun 25, 2008, at 1:19 AM, Tran Kim Bach wrote: 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

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

2008-06-24 Thread Kai
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 a

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

2008-06-24 Thread Tran Kim Bach
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