Re: Obj-C/C question (basic?)
Re: Obj-C/C question (basic?)
- Subject: Re: Obj-C/C question (basic?)
- From: Cameron Hayne <email@hidden>
- Date: Sat, 19 Oct 2002 04:12:05 -0400
On 19/10/02 3:33 am, "Hisaoki Nishida" <email@hidden> wrote:
>
There's a method with the prototype:
>
int someCmethod(struct foo *arg);
>
Obviously I need to pass it the address of myStruct.
>
But myStruct is of type struct bar, which is of the same size as struct
>
foo.
>
So I cast it (i am talking about sockaddr_in and sockaddr, if you know
>
these structs in C):
>
int a = someCmethod((struct foo *)&myStruct);
>
But what if I want to pass it a return value from my obj-c method:
>
- (struct bar *)objcmethod;
>
How would I put the return value directly in someCmethod?
>
int a = someCmethod((struct foo *)*[someobj objcmethod]);
>
That wouldnt work... would it?
No - not the way you have written it, with that extra '*' dereferencing the
pointer. But something like:
int a = someCmethod((struct foo *)[someobj objcmethod]);
should work.
It would be better if you gave us details of the actual methods you are
proposing to use instead of trying to make it generic. E.g. you might have
issues with having to free the memory returned from [someobj objcmethod].
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
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.