• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: id vs cast
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Prev by Date: Re: id vs cast
  • Next by Date: Creating NSmages from NSMovies for display in an NSOutlineView
  • Previous by thread: Re: id vs cast
  • Next by thread: Re: Is Objective-C loaded?
  • Index(es):
    • Date
    • Thread