Re: substring return a new string?
Re: substring return a new string?
- Subject: Re: substring return a new string?
- From: Ondra Cada <email@hidden>
- Date: Thu, 18 Mar 2004 12:00:28 +0100
Francisco,
On Thursday, Mar 18, 2004, at 07:41 Europe/Prague, Francisco Tolmasky
wrote:
When I have a textview, and call [[textview string]
substringWithRange: someRange], if I want to save that string, do I
need to send it the copy: message, or am I ok with just retaining it
(given that the string in the textview will be edited).
presumed you want a snapshot of the moment you called
substringWithRange:, *do* use copy! It is possible that in the current
implementation it is superfluous (but harmless), but it may change in
future.
Generally, *whenever you need a snapshot of the current state, use
copy*. Use retain only in case you explicitly want to *share* the
object.
There's a mechanism of mutable/immutable objects which ensures it is
ver efficient and you don't do any unnecessary copying in fact (unless
someone uses mutable objects for immutable data, which, of course, is a
design bug).
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.