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: Mon, 28 Jul 2003 18:58:30 -0700
On Monday, July 28, 2003, at 5:58 PM, Chris Purcell wrote:
Fritz Anderson wrote:
NSString * result = [ofProcessingObject processedString];
[ofProcessObject release];
NSLog(@"The result is %@", result);
I am entitled to assume that result has not been disposed-of, am I
not?
Yes. In this case, indubitably. Bad coding in OF, or bad choice of
method name. It translates as "the string that results from
ofProcessingObject's processing", not "the <property> of
ofProcessingObject". I'd say this is the exception that proves the
rule.
I'll interject here, since I may very well make coding changes in OF
based upon this thread. :-)
First, since there is no processedString method in OmniFoundation, I'm
assuming that Fritz was making a generic example and not talking about
a specific method name. Thus, "bad choice of method name" doesn't
really apply here.
If you saw these methods (some of many in OF):
- (NSString *)stringByUppercasingAndUnderscoringCaseChanges;
- (NSString *)stringByRemovingSurroundingWhitespace;
- (NSString
*)stringByCollapsingWhitespaceAndRemovingSurroundingWhitespace;
- (NSString *)stringByRemovingWhitespace;
- (NSString
*)stringByRemovingCharactersInOFCharacterSet:(OFCharacterSet
*)removeSet;
- (NSString *)stringByRemovingReturns;
- (NSString *)stringByRemovingString:(NSString *)removeString;
- (NSString *)stringByPaddingToLength:(unsigned int)aLength;
- (NSString *)stringByNormalizingPath;
Would you expect that calling, for instance,
-stringByRemovingWhitespace might return the same string object if
there was no whitespace in it? Should it be retained and autoreleased
because this isn't a property of the original string? Or would it be
preferable just to document this possibility and avoid the autorelease?
I know now what Fritz' expectation would be (by the way Fritz, did you
ever report this as a bug? I don't remember seeing anything about
it...)
Anyone else have an opinion?
Thanks,
- 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.