Quincey,

> On Aug 11, 2016, at 03:04, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
>> On Aug 10, 2016, at 23:32 , Sasikumar JP <jps...@gmail.com> 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.

Are there any real world examples of this in the Cocoa flora of objects?  If 
you had asked me before reading your response I would have called the behavior 
you describe a bug.  I would have said the result of -copy on an object should 
have the same -hash and return true for -isEqual:.  (Perhaps I need to expand 
my understanding here.)  Lastly, I would think if an object needed the behavior 
you describe, it would support this need with a special interface, like 
-duplicateWithCurrentDate.  Can you expound on this scenario?

> 
> 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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari....@gmail.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to