Re: cocoa-dev digest, Vol 2 #2711 - 14 msgs
Re: cocoa-dev digest, Vol 2 #2711 - 14 msgs
- Subject: Re: cocoa-dev digest, Vol 2 #2711 - 14 msgs
- From: Greg Titus <email@hidden>
- Date: Tue, 29 Jul 2003 09:09:28 -0700
On Tuesday, July 29, 2003, at 7:16 AM, Fritz Anderson wrote:
I've privately apologized to Greg for not reporting the behavior of
stringByRemovingSurroundingWhitespace as (in my opinion) a bug. Let me
also publicly regret making a generic slam on OF, without which much
fine work in Cocoa would not be possible. The lapse was gratuitous,
and all I can say is that I wasn't thinking.
Oh, hey, no problem. I agree that it was a bug. In fact, there were 5
other -stringByDoingWhatever methods in OF which had the same error:
- stringByPaddingToLength:
- stringByReplacingCharactersInSet:withString:
- stringBySeparatingSubstringsOfLength:
- stringByRemovingPrefix:
- stringByRemovingSuffix:
These are now fixed internally, and will be in the next OF source
release, whenever that may be.
Interestingly, in none of my currently checked out code (all the
frameworks, plus 3 of our apps, plus some test code) does it look like
this problem could ever have bitten us. About 80% of our uses of these
types of methods are in code with this pattern:
aString = [aString stringByRemovingSurroundingWhitespace];
Almost all the rest are using the results immediately in other string
processing steps:
aString = [NSString stringWithFormat:@"%@ - %@", [foo
stringByPaddingToLength:4], [bar stringByPaddingToLength:4]];
There is actually only one place (which happens to not be in published
code) where we _ever_ have pointers to both the original and the
modified string at the same time, and in that one place the original is
already autoreleased so we don't release it and so aren't open to the
possible bug.
- Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.