• 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: NSManagedObject, NSString property retain vs copy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSManagedObject, NSString property retain vs copy


  • Subject: Re: NSManagedObject, NSString property retain vs copy
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 30 Jul 2015 11:26:24 -0500

On 30 Jul 2015, at 11:03 AM, Trygve Inda <email@hidden> wrote:

> It seems Apple is using retain rather than copy for NSString properties in
> an NSManagedObject subclass.
>
> I was always under the impression that copy should be used for NSString, so
> why the retain??

For an immutable string, -copy is implemented as a -retain. -copy is a guard against the receiver’s relying on the unchanging contents of a string whose contents can be changed. If the contents cannot in fact be changed, there’s no point in allocating new memory and copying the bytes into it.

It’s an implementation detail; what makes you believe it makes a difference?

	— F


_______________________________________________

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


  • Follow-Ups:
    • Re: NSManagedObject, NSString property retain vs copy
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >NSManagedObject, NSString property retain vs copy (From: Trygve Inda <email@hidden>)

  • Prev by Date: NSManagedObject, NSString property retain vs copy
  • Next by Date: Re: problem with rangeOfString debugger warning
  • Previous by thread: NSManagedObject, NSString property retain vs copy
  • Next by thread: Re: NSManagedObject, NSString property retain vs copy
  • Index(es):
    • Date
    • Thread