Re: Appropriateness of assign attribute and -fobj-gc-only
Re: Appropriateness of assign attribute and -fobj-gc-only
- Subject: Re: Appropriateness of assign attribute and -fobj-gc-only
- From: Quincey Morris <email@hidden>
- Date: Sun, 21 Sep 2008 19:56:49 -0700
On Sep 21, 2008, at 18:08, Rick Mann wrote:
I was going to say...especially for immutable objects like NSString
and NSNumber, which you pointed out are almost always used as
attributes and not as relationships, it seems to make more sense
(from a performance standpoint, at least) to just assign the pointer
and not allocate a new object and copy the contents.
You can expect that copying of immutable objects like NSString and
NSNumber may not actually copy but return a reference to the original.
So you're better off declaring them "copy". Also keep in mind that
even if the property is declared as NSString*, a client may actually
pass a mutable string to the setter as the new value, and in that case
you really do want a copy.
Again, I'd recommend using "copy" or "assign" as a semantic descriptor
on the property, and not worry about the copying performance of the
implementation unless you discover a good measurable reason to do so.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden