Newbie: Object life within a method scope
Newbie: Object life within a method scope
- Subject: Newbie: Object life within a method scope
- From: Joseph Feld <email@hidden>
- Date: Tue, 22 Feb 2005 16:59:58 -0500
Hi all,
Trying to get a handle on the whole retain and release system (my day job is
in the Java world and the GC has definitely spoiled me) and I'm curious
about the life of an object within a method scope. I found the Memory
Management: Object Ownership and Disposal document on the Apple Dev site and
it states: "A received object is normally guaranteed to remain valid within
the method it was received in (exceptions include multithreaded applications
and some Distributed Objects situations). That method may also safely return
the object to its invoker," which would seem to answer my question.
However, two bullet points later it warns: "Use retain and autorelease when
needed to prevent an object from being invalidated as a normal side-effect
of a message," which has me a bit confused about what normal side-effects of
a message might cause me to lose my object.
So I guess my question is, if I'm not interested in an object beyond the
scope of the method receiving it is it still prudent to retain it to ensure
it survives the scope, or is that unnecessary?
Thanks,
Joe
_______________________________________________
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