• 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: NSArray, NSDictionary property attribute issue, retain or copy?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray, NSDictionary property attribute issue, retain or copy?


  • Subject: Re: NSArray, NSDictionary property attribute issue, retain or copy?
  • From: Mike Abdullah <email@hidden>
  • Date: Sun, 13 Nov 2011 11:31:32 +0000

You should indeed declare such properties as copy. Some people seem to assume that the copy will copy the contents of the collection, which certainly isn't true. Of course for NSArray, it's often more appropriate to have a readonly array property, with KVC-compliant methods for inserting and removing objects.

On 13 Nov 2011, at 08:48, ico wrote:

> Hi all,
>
> We always use copy attribute on the NSString property declaration because
> it will figure it out that when you pass a mutable copy, if will copy then
> make the object to be immutable version and assign it to your property, and
> it will retain if you pass an immutable version.
> That's very cool and is the most often situation we want.
>
> However, I really hard to see people use the same technique on NSArray and
> NSDictionary.
> If the reason for NSString holds true, why not we also use copy on NSArray
> and NSDictionary property declaration?
> I see most of time, developer just use retain attribute on them.
>
> why?
>
> --
> ==========================
> Life isn't about finding yourself.
> Life is about creating yourself.
> _______________________________________________
>
> 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

_______________________________________________

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: 
 >NSArray, NSDictionary property attribute issue, retain or copy? (From: ico <email@hidden>)

  • Prev by Date: Re: About iVars declaration and property
  • Next by Date: Re: NSArray, NSDictionary property attribute issue, retain or copy?
  • Previous by thread: NSArray, NSDictionary property attribute issue, retain or copy?
  • Next by thread: Re: NSArray, NSDictionary property attribute issue, retain or copy?
  • Index(es):
    • Date
    • Thread