• 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: Newbie question: getting an object back from just a pointer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie question: getting an object back from just a pointer


  • Subject: Re: Newbie question: getting an object back from just a pointer
  • From: Keary Suska <email@hidden>
  • Date: Sat, 24 Feb 2007 11:36:34 -0700
  • Thread-topic: Newbie question: getting an object back from just a pointer

on 2/24/07 5:35 AM, email@hidden purportedly said:

>    QTMovie*  movie = [QTMovie movieWithURL:url error:&initError];
<snip>
>
>    // let's just test that, shall we?
>    NSLog (@"SelectorHelper re-casting movie...");
>    QTMovie* movieTest = (QTMovie*) &movie;


If the "movie" is the same in both snippets, why are you casting a pointer
to it? I would think movie is already a pointer, or there is something more
seriously wrong. Instead you probably want (note no ampersand):

QTMovie* movieTest = (QTMovie*) movie;

You may, in several places, be making a common "newbie" (or Java programmer
;-) mistake of not treating objects as pointers. This piece:

   NSLog (@"Created QTMovie %@ at address %u", movie, &movie);

Is also wrong, at least in the extent that if you want output of movie's
pointer value, you would simply:

   NSLog (@"Created QTMovie %@ at address %p", movie, (void *)movie);

The void * shouldn't be necessary, but it may make what you are doing
explicit.

Finally, in C, & means make-pointer-to and * means dereference-pointer.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Newbie question: getting an object back from just a pointer (From: Chris Adamson <email@hidden>)

  • Prev by Date: Re: NSTabView help
  • Next by Date: Implications of changing an app's bundle identifier
  • Previous by thread: Re: Newbie question: getting an object back from just a pointer
  • Next by thread: Bindings and multiple ArrayControllers
  • Index(es):
    • Date
    • Thread