Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: id vs cast



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.


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.