• 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: Beginner question about strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beginner question about strings


  • Subject: Re: Beginner question about strings
  • From: Shawn Erickson <email@hidden>
  • Date: Sun, 04 Jun 2006 15:46:05 -0700


On Jun 4, 2006, at 3:41 PM, D.K. Johnston wrote:

I'm not sure about the status of strings returned by methods like "substringFromIndex:". I know that they're new strings. But how long do they last? Are they autoreleased? If an object method returns one of these strings to another object, should the string be sent a "retain" message? etc.

Does that method have the word alloc, new, or copy in it? Do the docs for that method say anything special?


Nope :)

so... the string returned from that method is not "owned" by you and hence could go away at anytime in the future. If you need it hang around you need to retain it for as long as you need it (when done with it you of course need to balance your retain with a release).

-Shawn
_______________________________________________
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


References: 
 >Beginner question about strings (From: "D.K. Johnston" <email@hidden>)

  • Prev by Date: Re: Beginner question about strings
  • Next by Date: Re: Saving an NSImage to an image file
  • Previous by thread: Re: Beginner question about strings
  • Next by thread: Programmatically setting up a NSTextField
  • Index(es):
    • Date
    • Thread