• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Appropriateness of assign attribute and -fobj-gc-only
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Appropriateness of assign attribute and -fobj-gc-only (From: Rick Mann <email@hidden>)
 >Re: Appropriateness of assign attribute and -fobj-gc-only (From: Quincey Morris <email@hidden>)
 >Re: Appropriateness of assign attribute and -fobj-gc-only (From: Quincey Morris <email@hidden>)
 >Re: Appropriateness of assign attribute and -fobj-gc-only (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: NSScroller will be visible even it is below other view in 10.4
  • Next by Date: Re: Programmatically inserting text into NSTextView and scrolling
  • Previous by thread: Re: Appropriateness of assign attribute and -fobj-gc-only
  • Next by thread: Re: Appropriateness of assign attribute and -fobj-gc-only
  • Index(es):
    • Date
    • Thread