Re: substring return a new string?
Re: substring return a new string?
- Subject: Re: substring return a new string?
- From: Shawn Erickson <email@hidden>
- Date: Thu, 18 Mar 2004 09:45:12 -0800
On Mar 18, 2004, at 9:12 AM, Ondra Cada wrote:
Marco,
On Thursday, Mar 18, 2004, at 17:32 Europe/Prague, Marco Scheurer
wrote:
so far as I can say the only remaining possibility is to *declare*
the method returning mutable data, and *document* the fact it is
always freshly-created: let then the client decide what to do with
>> it:
@interface ...
...
-(NSMutableArray*)someArray; // created each time the message is
sent, not stored then
...
// implementation exactly as you suggested.
Certainly not! Declaring the method as returning NSMutableArray
documents the fact that the user can modify the returned array. This
is most likely not what you want.
Why not, in this case? Nobody can ever share the array with the user
(who may change it), unless the user (who may change it) allows it
himself, so I would say all right. Am I overlooking something
important?
Yeah as long as the implementation does something like what was
outlined in your email it is safe. Of course you are forcing your
implementation to be done in a more specific way as a result of
interface definition. Less freedom in implementation may or may not be
an issue depending on the target "market" so to speak of your class.
-Shawn
_______________________________________________
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.