v10.3
-
The release contains binary wheels for Python 3.13
PyObjC does at this time not support the experimental free threading
support in Python 3.13. -
#569: Removed the workaround for a bug in Xcode 15.0
The workaround is no longer necessary, and caused problems when
building with the Command Line Tools development tools from Apple. -
Updated SDK bindings for macOS 14.5
-
A minor change in the (currently private) tooling I use for
collecting the raw metadata resulted in minor fixes to the framework
bindings, in particular for metadata for a number of block and function
typed arguments and return values. -
#275: It is now possible to create instances of Objective-C
classes by calling the class, e.g.NSObject()
instead of
NSObject.alloc().init()
.The implementation of
__new__
forwards calls to the underlying
SomeClass.alloc().init...()
pattern. In particular, all public init
methods are translated into sets of keyword arguments:- Remove
init
orinitWith
from the start of the selector name - Lowercase the first character of what's left over
- The strings before colons are acceptable keywords, in that order
For example, given a selector
initWithX:y:
the__new__
method
will acceptx, y
as keyword arguments, in that order.Framework bindings have been updated with additional metadata to support
this pattern, and the sets of keyword arguments are automatically calculated
for subclasses in written in Python.The limitation on the order of keyword arguments may be lifted in a future
version, it is currently present to keep the code closer to the Objective-C
spelling which should make it easier to look up documentation on Apple's
website. - Remove
-
For some Objective-C classes some of the
init
andnew
methods are not
available even if they are available in super classes. Those methods are
marked withNS_UNAVAILABLE
in Apple's headers.As of this version these methods are also not available in Python code,
trying to call them will result in an exception.To make methods unavailable in Python classes set these methods to
None
,
e.g.:class MyObject(NSObject): init = None # NS_UNAVAILABLE
-
Added :func:
objc.registerUnavailableMethod
,
:func:objc.registerNewKeywordsFromSelector
and
:func:objc.registerNewKeywords
to support the generic__new__
in framework bindings.A limitation for
registerUnavailableMethod
is that it is currently
not supported to reintroduce the method in a subclass, primarily because
that functionality is not needed for framework bindings. -
Instantiating an Objective-C class by calling the class (e.g. invoking
__new__
) will not call__init__
even if one is defined.The implementation of a subclass of
NSObject
should always follow
the Objective-C convention for initializing using one or more
methods with a name starting withinit
.This can affect code that manually defines a
__new__
method for
an Objective-C class, in previous versions that was the only way
to create instances in a Pythontic way. -
NSArray
,NSMutableArray
,NSSet
andNSMutableSet
accepted
asequence
keyword argument in previous versions. This is no longer supported.It is still supported to create instances using a positional argument
for a sequence, e.g.NSArray([1, 2, 3])
. -
NSData
,NSMutableData
,NSDecimal
,NSString
andNSMutableString
accepted avalue
keyword argument in previous versions. This is no longer supported.It is still supported to create instances using a positional argument,
e.g.NSData(b"hello")
. -
NSDictionary
andNSMutableDictionary
do not support the
generic new interface because this conflicts with having a similar
interface todict
for creating instances.That is,
NSDictionary(a=4, b=5)
is the same asNSDictionary({"a":4, "b":5})
,
and not likeNSDictionary.alloc().initWithA_b_(4, 5)
.