• 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: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)


  • Subject: Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
  • From: Sasikumar JP <email@hidden>
  • Date: Thu, 11 Aug 2016 17:01:01 +0530

Quincey, David,

 Thank you for the detailed explanation.

Regards
Sasikumar JP

On 11 August 2016 at 12:34, Quincey Morris <
email@hidden> wrote:

> On Aug 10, 2016, at 23:32 , Sasikumar JP <email@hidden> wrote:
>
>
> what was the reason NSNumber conforms to NSCopying protocol.
>
>
> 1. It actually inherits conformance from its superclass, NSValue.
>
> 2. The fact than an object is immutable does not (in general) mean that a
> copy can be represented by the same object reference. For example, an
> object that contained its own date of creation might be immutable, but a
> copy might have a different date, and therefore be a different object.
> Putting this another way, the immutability does not make NSCopying
> conformance irrelevant.
>
> 3. NSNumber is one of a group of classes that represent “serializable”
> objects (for property lists, for example). Since these are often arranged
> in heterogenous hierarchies using arrays, sets and dictionaries, it’s
> convenient that they share behavior. If all property list classes conform
> to NSCopying, then property lists can be deep copied without special code.
>
> 4. Objects used as NSDictionary keys must conform to NSCopying. It would
> be a hardship if this excluded NSNumber.
>
> So it turns out to be easier to have NSNumber conform to NSCopying, than
> to avoid conformance.
>
>
_______________________________________________

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: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
      • From: Dave <email@hidden>
References: 
 >Objective-C basics - (Why NSNumber conforms to NSCopying protocol) (From: Sasikumar JP <email@hidden>)
 >Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol) (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
  • Next by Date: Drag and Drop on iOS
  • Previous by thread: Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
  • Next by thread: Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
  • Index(es):
    • Date
    • Thread