P.220 More about copying ... I am missing the point



on page 220 is explained that sending a copy message to an Appliance object results in an error. I tried this out, and indeed this results in an error, however I don’t get the point why …

  • the method ‘copy’ IS defined in NSObject
  • copy calls copyWithZone as shown in the code page 220
  • Appliance inherits from NSObject

then why is this an unrecognized selector ?


copyWithZone: is not defined in NSObject. So when the copy method calls

, an exception is thrown.


ok i c … just went through the NSObject doc, if I understand it correctly, when I would like to have a ‘copy’ method for the Appliance class, I need to override ‘copyWithZone’ (same for ‘mutableCopyWithZone’)


Exactly correct. We implement copyWithZone:, but we typically call copy.