• 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: Best Way to Handle Properties?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best Way to Handle Properties?


  • Subject: Re: Best Way to Handle Properties?
  • From: Charles Srstka <email@hidden>
  • Date: Wed, 20 Aug 2008 17:20:42 -0500

On Aug 20, 2008, at 12:42 PM, Dave wrote:

The copy operation here, copies that data from one string to a newly allocated string, right?

Only if it's mutable. If it's immutable, it's most likely that copy will just do the same thing as retain - since that object isn't going to change, there's little point in making a whole copy of it, so Apple does basically the same optimization that you were trying to do.


For this reason, it's usually best just to use copy - most of the time there will be no additional allocation since it's just doing the same thing as retain, and when there *is* an additional allocation, it's usually when you actually need it - for example, you don't want some other object to accidentally mutate some object that's in your object's internal state, so if you're given a mutable object, the best thing to do is make a copy so that you can know that the object won't change behind your back.

Charles
_______________________________________________

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: 
 >Best Way to Handle Properties? (From: Dave <email@hidden>)
 >Re: Best Way to Handle Properties? (From: Ken Thomases <email@hidden>)
 >Re: Best Way to Handle Properties? (From: Dave <email@hidden>)
 >Re: Best Way to Handle Properties? (From: Ken Thomases <email@hidden>)
 >Re: Best Way to Handle Properties? (From: Dave <email@hidden>)
 >Re: Best Way to Handle Properties? (From: Ken Thomases <email@hidden>)
 >Re: Best Way to Handle Properties? (From: Dave <email@hidden>)

  • Prev by Date: Re: NSToolbar within view
  • Next by Date: Re: Control-Click vs Right-Click in NSTableView
  • Previous by thread: Re: Best Way to Handle Properties?
  • Next by thread: Re: Best Way to Handle Properties?
  • Index(es):
    • Date
    • Thread