Re: Yet another memory management question
Re: Yet another memory management question
- Subject: Re: Yet another memory management question
- From: j o a r <email@hidden>
- Date: Fri, 8 Sep 2006 17:52:40 +0200
On 8 sep 2006, at 17.32, Bruce Truax wrote:
selectorString = [[NSString alloc] initWithString:@"set"];
You allocate a string here...
selectorString = [selectorString
stringByAppendingString:tempString];
...and replace that string (leaking it) with a new, autoreleased,
string here.
When you then autorelease, the already autoreleased, string, you lay
the foundation for the crash that follows.
There is a simple pattern that you might want to consider. Whenever
you create temporary objects, do this:
id myTempObj = [[[ObjClas alloc] init] autorelease];
In this way you don't have to worry about getting your release
statements right at the end of your method. Much less risk for copy-
paste bugs, etc.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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