Re: Memory Management
Re: Memory Management
- Subject: Re: Memory Management
- From: mmalcolm crawford <email@hidden>
- Date: Mon, 28 Jul 2003 15:16:02 -0700
On Monday, July 28, 2003, at 12:50 PM, Fritz Anderson wrote:
Why, then, is this not a bug:
NSString * result = [myNamedObject name];
[myNamedObject release];
NSLog(@"The name was %@" result); // MPW wants an access exception
here.
You are not allowed to answer that I am _supposed to know_ how -name
is implemented.
Senders of messages with NSObject * replies should be able to assume
that the replies have at least autorelease lifetimes.
Some of these issues are discussed here:
<
http://www.stepwise.com/Articles/Technical/2002-06-11.01.html>
In this case, the fact that you *release* (rather than autorelease) the
containing object might reasonably give anyone cause for concern. The
default assumption in using returned objects should be that, unless you
take steps to keep them, they may disappear out from under you (as is
fairly clear in this case). Therefore you might be well-advised to
retain any objects you access which are properties of another object
which you subsequently dispose of.
mmalc
_______________________________________________
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.