• 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: Does retain not work on ids?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does retain not work on ids?


  • Subject: Re: Does retain not work on ids?
  • From: Pandaa <email@hidden>
  • Date: Tue, 24 May 2005 03:53:16 +0200


24 maj 2005 kl. 03.40 skrev Ken Tozier:

I have a struct in which one field (type = id) serves as a generic "data" object. In my initialization method, i've tried several different ways to retain the field, but when a later method goes to access it, it's always nil. In the past, I've not noticed any difference between sending a message to the id of objects rather than an "official" object.

<cut>

Is "retain" an exception to this rule?

No. It seems like either the object passed to your initialization method is nil, or you have made a mistake in your assignment. It's impossible to tell without looking at your code, and the example your provided does not seem to clarify your problem.


You can send any method to an object reference typed as id, there are no exceptions to this. Message dispatch is dynamic, and unaffected by the static type of the reference.

Most probably, the retain is not what is causing your problem. If you had forgotten to retain the object and it were released, your reference would still point to the memory address where the object once resided rather than being magically reset to nil.

If you post the relevant initialization method, perhaps we can see where the mistake lies.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. email@hidden . . www.synapticpulse.net .


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Does retain not work on ids?
      • From: Ken Tozier <email@hidden>
References: 
 >Does retain not work on ids? (From: Ken Tozier <email@hidden>)

  • Prev by Date: Does retain not work on ids?
  • Next by Date: Text Formatting (NSAttributedString?)
  • Previous by thread: Does retain not work on ids?
  • Next by thread: Re: Does retain not work on ids?
  • Index(es):
    • Date
    • Thread