Re: A quick memory (release) question
Re: A quick memory (release) question
- Subject: Re: A quick memory (release) question
- From: Clark Cox <email@hidden>
- Date: Tue, 31 Jan 2006 08:23:23 -0500
On 1/31/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?
No, they don't. Both of your examples were obtained from alloc,
period. So, you are responsible for releasing them.
--
Clark S. Cox III
email@hidden
My CV/Resume:
http://homepage.mac.com/clarkcox3/files/Resume.pdf
http://homepage.mac.com/clarkcox3/files/Resume.html
_______________________________________________
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