lakka committed 268854b

Updating copying

Comments (0)

Files changed (1)


+It is possible for a Python subclass of an Objective-C class to implement
+the ``NSCopying`` protocol.  Some care must be taken when the superclass
+already implements the protocol. 
+Some ``NSCopying`` compliant Objective-C classes copy the template object
+manually.  In those cases the Python subclass must also copy the additional
+ivars manually.
+Other ``NSCopying`` compliant Objective-C classes use a convenience function
+that creates a shallow copy of the object and all of its ivars.  In those
+cases the Python subclass will not have to explicitly copy all of the ivars.
+However, the ivars in the copy will refer to the same objects as the original,
+and will thus share some state.  As with shallow copies in Python, if any of
+the ivars refer to mutable objects (``list``, ``dict``, etc.) it may be
+desirable to explicitly make shallow or deep copies of the mutable ivars.
+.. note:: 
+    PyObjC might introduce a helper class when you inherit from a class
+    that implements ``NSCopying`` as an internal implementation detail.
+    External code should not rely on the existance of this class.
+.. note::
+    ``SomeClass.copyWithZone_`` should not be implemented unless a
+    superclass already implements ``copyWithZone:``, or else the behavior
+    will be undefined (memory corruption, crashes, etc.).
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.