Re: id vs cast
Re: id vs cast
- Subject: Re: id vs cast
- From: Edward Fink <email@hidden>
- Date: Sat, 7 Dec 2002 01:20:46 -0500
I assume you don't have ownership of that function? Because if you
know, as you seem to, that it returns a pointer of a very specific
type, it seems perverse to declare it as a function returning (void > *).
I do not have ownership of the function.
void * thePointer; // known to point to a TheClass
TheClass * myObject;
id alsoMyObject;
myObject = (TheClass *) thePointer; // A
alsoMyObject = (id) thePointer; // B
Both A and B will compile to a single load of a register. There's no
run-time difference.
What I have used successfully is your "A" example and the following:
id alsoMyObject = thePointer;
It is this 2nd way I was able to use the pointer (not the "B" you have
shown) that I was curious about. Is it correct to do it in this
manner...and is it any faster? From your post it sounds like the "A"
example is already extremely fast...so I am guessing there is no need
to do it any other way.
_______________________________________________
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.