------------------------
- New ``objc.pyobjc_id`` function that returns a the id of the underlying
NSObject as an integer. (Python wrapper objects are often made on the
fly, meaning ``id(obj)`` is not constant during the lifetime of the
object.)
- The bridge now maintains object identity across the bridge
in both directions. Previous versions of the bridge only did this when
bridging from Objective-C to Python.
Exceptions: ``NSString`` and ``NSNumber`` do not have unique proxies. These
types are converted to subclasses of Python types as appropriate, so they
can not have unique proxies. The identity of the original Objective-C
object is maintained by these subclasses, but there may be many Python
"value proxies" for a single Objective-C object.
Any Python object that is proxied using the ``__pyobjc_object__``
interface will only get a unique proxy if the ``__pyobjc_object__``
method implements that feature.
- New ``objc.protocolsForClass`` function that returns a list of protocols
that the class directly claims to conform to.
- PyObjC classes can now declare that they implement formal protocols,
for example:
.. sourcecode:: python
class MyLockingClass(NSObject, objc.protocolNamed('NSLocking')):
implementation
pass
It is also possible to define new protocols:
.. sourcecode:: python
MyProtocol = objc.formal_protocol("MyProtocol", None, [
selector(None, selector='mymethod', signature='v:'),
])
All formal protocols are instances of ``objc.formal_protocol``.
- PyObjCTools.KeyValueCoding has a new ``kvc`` class that allows
Pythonic Key-Value Coding.
- ``__getitem__`` is mapped to ``valueForKeyPath:``
- ``__setitem__`` is mapped to ``setValue:forKeyPath:``
- ``__getattr__`` is mapped to ``valueForKey:``
- ``__setattr__`` is mapped to ``setValue:forKey:``
The ``kvc`` class uses ``__pyobjc_object__``, so it may cross the bridge
as the wrapped object.
- ``NSNumber`` instances are bridged to a ``float``, ``long``, or ``int``
subclass that uses ``__pyobjc_object__``.
``NSDecimal`` is converted to ``NSDecimalNumber`` when used as an object,
``NSDecimalNumber`` is not bridged to ``NSDecimal`` because the latter is
a mutable type.
- The Python to Objective-C bridge now looks for a ``__pyobjc_object__``
attribute to get a PyObjC object from a Python object.
- New IDNSnitch example in Inject that demonstrates how to write an
monitor for the launch of another application,
use ``objc.inject`` to load code into a target process,
and override the implementation of an existing method but still
call back into the original implementation (method swizzling).
- ``objc.IMP`` should do the right thing now. This type is returned
by ``+[NSObject methodForSelector:]`` and
``+[NSObject instanceMethodForSelector:]``
- New ToDos example in CocoaBindings that demonstrates how to use
two array controllers for the same data, and how to use value
transformers to alter the color of text. Originally from
"Cocoa Bindings Examples and Hints", converted to PyObjC by u.fiedler.
- New Bookmarks example in CocoaBindings that demonstrates how to
subclass ``NSArrayController`` to implement the ``NSTableView``
delegate drag and drop protocol, including copying of objects between
documents and accepting URL drops from other applications. Also
demonstrates re-ordering of the content array. Originally from
"Cocoa Bindings Examples and Hints", converted to PyObjC by u.fiedler.
- New FilteringController example in CocoaBindings that demonstrates
how to subclass ``NSArrayController`` to implement filtering
of a ``NSTableView``. Also demonstrates the use of indexed accessors.
Originally from "Cocoa Bindings Examples and Hints", converted to PyObjC
by u.fiedler.
- New ControlledPreferences example in CocoaBindings that demonstrates
how to use Cocoa Bindings to simplify storing and retrieving user
preferences. Originally from "Cocoa Bindings Examples and Hints",
converted to PyObjC by u.fiedler.
- New TemperatureTransformer example in CocoaBindings that demonstrates
how to use NSValueTransfomers with PyObjC. Based on Apple's
"Cocoa: Value Transformers" documentation, converted to PyObjC
by u.fiedler.
- New CurrencyConvBindings example in CocoaBindings that demonstrates
a Cocoa Bindings enabled version of the CurrencyConverter example.
Converted to PyObjC by u.fiedler from the example in Apple's
"Introduction to Developing Cocoa Applications Using Bindings".
- New ManualBindings example in CocoaBindings that demonstrates how
to develop programmatic bindings from a PyObjC application.
Converted to PyObjC by u.fiedler from the "Cocoa Bindings and Hints"
example of the same name.
- New HotKeyPython example in AppKit that demonstrates how to use
Carbon global hot keys from a PyObjC application. Also demonstrates
how to use a NSApplication subclass.
- Key-Value Observing support is now automatic in Python classes that
descend from ``NSObject``, unless they implement a custom
``willChangeValueForKey:``, ``didChangeValueForKey:``, or
``__useKVO__`` is not True. This allows ``self.foo = 1`` to
automatically trigger notifications. This works in all cases,
whether ``foo`` is a ``property``, ``ivar``, or just in the
``__dict__``.
- New Inject folder in Examples, with an InjectInterpreter
example that will inject a GUI Python interpreter into any process.
- New ``objc.inject()`` function for macOS 10.3 and later,
allows an arbitrary bundle to be loaded into another process
using mach_inject.
- ``objc.classAddMethods`` now recognizes and supports
classmethods.
- GC is now correctly implemented for struct wrappers.
- The ``NSNumber`` bridge has been removed, now you will get
``NSNumber`` instances across the bridge instead of a
Python representation.
- ``PyObjCTools.AppHelper.runEventLoop()`` will now bring your
application to the front at startup when using pdb
mode for convenience.
- ``objc.loadBundle()`` no longer filters the class list. This
solves a few potential issues and shaves off about 1/3rd of
the overhead of ``python -c "import AppKit"``.
- ``PyObjCTools.AppHelper.runEventLoop()`` no longer breaks on
pure Objective-C exceptions. Most exceptions of this variety
are more like warnings, and there is nothing that can be done
them anyway.
- ``PyObjCTools.AppHelper.runEventLoop()`` now installs the
interrupt handler and verbose exception logging when using pdb,
either explicitly or by the USE_PDB environment variable.
- There is now a fast path for the ``NSString``/``unicode``
bridge when ``Py_UNICODE_SIZE`` is 2. This is the default
setting for Python.
- The default selector signature will have a void return value
unless a "return" statement with an argument is used in the
bytecode. In that case, it will default to an object return
value.
- ``__bundle_hack__`` is no longer necessary, py2app now sets
a different environment variable to the current plugin during
execution, and a hack is installed to ``NSBundle`` so that classes
may respond to requests for their bundle with the ``+bundleForClass``
method. The class builder adds a default implementation of this to
Python classes if this environment variable is set.
- Added ``objc.currentBundle()``, which is equivalent to
``NSBundle.mainBundle()`` except after loading a plug-in.
Makes it easier to load nib files.
- ``PyObjCTools.NibClassBuilder.extractClasses()`` now uses
``objc.currentBundle()`` instead of ``NSBundle.mainBundle()``. This
makes plugins less of a hassle to develop and allows identical code
to be used for application or plugin development.
- ``objc.registerPlugin()`` and ``objc.pluginBundle()`` are now deprecated
as they are no longer useful.
- It is now possible to subclass a class that implements ``copyWithZone:``
without setting ``__slots__`` to ``()``.
- It is now possible to override ``dealloc``. It is still possible to
define ``__del__``.
- As an experimental feature it is also possible to override ``retain`` and
``release``. Note it almost never a good idea to do this (even when you're
programming in Objective-C and much more so in Python).
- ``poseAsClass:`` can be used, although it is not very useful in python, use
categories instead.
A major issue with ``poseAsClass:`` is that existing references to the old
version of the class won't be changed to point to the new class.
- It is now possible to access all instance variables of a class using
the functions ``objc.listInstanceVariables(aClassOrInstance)``,
``objc.getInstanceVariable(obj, name)`` and
``objc.setInstanceVariable(obj, name, value [, updateRefCount])``.
The last argument of ``setInstanceVariable`` is required when the instance
variable is an object. If it is true the bridge will update reference counts,
otherwise it won't.
- All wrappers for opaque pointers (such as ``NSZone*``) now have the same
interface and share a single implementation. This decreases code-size and
makes it easier to add new wrappers. A new feature is a ``__typestr__``
attribute on the type object, this contains the encoded Objective-C type
of the pointer.
A function for creating new wrappers is exposed to python, as
``objc.createOpaquePointerType(name, typestr, doc)``. The same function is
also exposed in the C-API.
- Wrappers for C-structs how have a ``__typestr__`` attribute on their type.
This attribute contains the encoded Objective-C type of the struct.
The default ``__init__`` for struct-wrappers now initializes fields with an
appropriate default value, instead of ``None``.
New wrappers can now be created from Python using the function
``objc.createStructType(name, typestr, fieldnames, doc)``. The same
function is also exposed in the C API (and has been for a while).