Re: Using NSMutableString* for NSString* result
Re: Using NSMutableString* for NSString* result
- Subject: Re: Using NSMutableString* for NSString* result
- From: j o a r <email@hidden>
- Date: Fri, 3 Oct 2003 18:04:16 +0200
I would suggest this implementation:
- (NSString *) getSomeFancyString
{
NSMutableString* s = [NSMutableString string];
[s appendString:getSomeOtherString()];
// ... Other stuff to add/change the string
return s;
}
Note that I create the string autoreleased to begin with - use the
convenience methods when possible! Also, using "new" is generally
discouraged IIRC, use [[myClass alloc] init] instead.
I don't think that you need to create an immutable copy of the returned
string - as long as you don't play tricks later, and knowing that it's
really a mutable string starts mutating it behind the back of other
objects that correctly treats it like an immutable string.
j o a r
_______________________________________________
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.