Re: Simple memory problem
Re: Simple memory problem
- Subject: Re: Simple memory problem
- From: Steve Sisak <email@hidden>
- Date: Thu, 5 Feb 2009 19:42:27 -0500
At 12:17 AM +0000 2/6/09, harry greenmonster wrote:
So, how do I keep a copy hanging around AND kill the mysterious new
copy then (which shares the same name as the old one presumably)?
Retain the copy you want to keep around manually:
while([inputString isMatchedByRegex:regexString])
{
NSAutoreleasePool* pool = [NSAutoreleasePool new];
range = [inputString rangeOfRegex:regexString];
NSString * newString = [inputString
stringByReplacingCharactersInRange:range withString:@""];
[inputString release]; // release old inputString
inputString = [newString retain]; // retain new inputString
[pool drain];
}
WARING: this code not tested for correctness but should give you the idea
The autorelease pool may or may not be necessary here, but given the
size of the input may be good defensive coding.
-Steve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden