• 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: A quick memory (release) question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A quick memory (release) question


  • Subject: Re: A quick memory (release) question
  • From: John Buckley <email@hidden>
  • Date: Tue, 31 Jan 2006 09:15:08 +0000

Paul,

You are correct in stating that the rule is *any* object you create
via alloc and some sort of init method is implicitly retained and must
be released by the caller. AFAIK there are no exceptions to this.

The autoreleased version of initWithFormat is +stringWithFormat.

John

On 31/01/06, Paul Harvey <email@hidden> wrote:
> Two quick examples:
>
> 1  NSMutableAttributedString *ns = [[NSMutableAttributedString alloc]
> initWithString: chapterText];
>
> 2  NSString *lookFor = [[NSString alloc]initWithFormat:@"\n%d",i];
>
> The rule for memory management says that if you obtain an object
> through alloc, you have retained it and it must be manually released
> at a later point.
>
> Yet methods like initWithFormat create an autoreleased object don't
> they?
>
> Trying to be a Good Programmerâ„¢ I was releasing the objects myself
> but that caused problems with my app, yet the problem has gone now
> i've removed these lines.
>
>
>
> --
> Paul Harvey
>
> Lead Programmer
> email@hidden
>
> Hiddenfield Software
> "Creating useful software for Mac OS X"
> www.hiddenfield.com
>
>
>  _______________________________________________
> 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
>


--
------------------------
Dr. John Buckley
email@hidden

Mac OS X Tiger
------------------------
 _______________________________________________
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: 
 >A quick memory (release) question (From: Paul Harvey <email@hidden>)

  • Prev by Date: A quick memory (release) question
  • Next by Date: Re: A quick memory (release) question
  • Previous by thread: A quick memory (release) question
  • Next by thread: Re: A quick memory (release) question
  • Index(es):
    • Date
    • Thread