| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Jan 31, 2006, at 5:23 AM, Clark Cox wrote:
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.
For example, if I call:
However, if I call:
Does that make sense?
Scott
_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
| References: | |
| >A quick memory (release) question (From: Paul Harvey <email@hidden>) | |
| >Re: A quick memory (release) question (From: Clark Cox <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.