• 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: Memory Management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Memory Management (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: Hard Objc-Runtime question: objc_getClassList lies to me...
  • Next by Date: Re: Memory Management
  • Previous by thread: Re: Memory Management
  • Next by thread: Re: Memory Management
  • Index(es):
    • Date
    • Thread