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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to