• 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: autorelease use...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autorelease use...


  • Subject: Re: autorelease use...
  • From: Charilaos Skiadas <email@hidden>
  • Date: Mon, 18 Jul 2005 11:46:59 -0500

On Jul 18, 2005, at 9:20 AM, Tristan O'Tierney wrote:

- ( void ) myFunction {
NSString *str = [NSString stringWithString: @"my string"];
[str retain];
}

Unless I'm mistaken, this will leak, no? str is a local variable declared in the function, so it is lost the moment you exit the function, and the retained object sticks around forever. I am guessing what you meant was the same without NSString * in front, where it is assumed that str is an instance variable of the object in question?
Or have I gotten it all wrong?


To Luc: Joar's email really nailed the issue. You should think of memory management in terms of ownership. Should your object own the other object or not?

Haris


_______________________________________________ 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: autorelease use...
      • From: "Tristan O'Tierney" <email@hidden>
References: 
 >autorelease use... (From: Luc Vandal <email@hidden>)
 >Re: autorelease use... (From: "Tristan O'Tierney" <email@hidden>)

  • Prev by Date: Re: Getting font attributes from an NSTextView
  • Next by Date: BSD Socket Send With NSString
  • Previous by thread: Re: autorelease use...
  • Next by thread: Re: autorelease use...
  • Index(es):
    • Date
    • Thread