• 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 of NSStrings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory management of NSStrings


  • Subject: Re: Memory management of NSStrings
  • From: Matteo Ceruti <email@hidden>
  • Date: Sun, 10 Apr 2005 13:58:26 +0200

James,

I do something like this:

    NSString* rpt =  @"#session( \r";

and then multiple lines of the sort:

    rpt = [rpt stringByAppendingString : objectString];
where objectString is built up in a similar way to make an report record.

finally I return rpt.

However it seems from my reading I should give a "[rpt autorelease]" before I return,
but if I do I get a double release error.  I can not find anything in the
documentation or my many books explaining how rpt gets into the autorelease pool
automatically, but I guess it does. And I probably missed it.  Could someone give me
a reference or a general rule when this happens.

don't count on me, because I'm quite a newbie too, but I am not surprised that stringByAppendingString seems to return an autoreleased String. I believe you can assume this, because the method's name begins with 'string', which corresponds to the class-name. Similar to the factory methods of a class like:

[NSString stringWithCString: "Hi everybody!"]

This ends up with an autoreleases object. I can't recall where it's written, but this is one convention.
Please correct me, if I am wrong.

Regards,
Matteo
 _______________________________________________
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: 
 >Memory management of NSStrings (From: John James <email@hidden>)

  • Prev by Date: Memory management of NSStrings
  • Next by Date: Re: Memory management of NSStrings
  • Previous by thread: Memory management of NSStrings
  • Next by thread: Re: Memory management of NSStrings
  • Index(es):
    • Date
    • Thread