An introduction to PyObjC describes the general method for translating Objective-C calls into Python calls, including the handling of pass-by-reference arguments and buffers.
This document describes where the PyObjC bindings for this framework are different from the general rule, such as mentioning APIs that are not supported or where the interface is different than expected.
See API Description for PyObjCTools.FndCategories for some API extensions for the Foundation framework.
These classes are barely supported, interaction with the lowlevel AppleEvent machinery is not tested at all and probably doens’t work.
Use the ScriptingBridge and/or the appscript library instead of this class.
-getBytes:: Use -bytes instead.
will try to use the C function free() on the buffer when the data object is released and that won’t work.
+dataWithBytesNoCopy:length:freeWhenDone:, -initWithBytesNoCopy:length:freeWhenDone:: Using these is fairly dangerous, your program can crash when the data buffer is cleaned up by the Python garbage collector before the NSData object is deallocated.
The freeWhenDone argument must be False.
Use buffer(value) instead, those will automaticly be bridged to an instance of a NSData subclass.
This method is not supported.
NSDebugEnabled, NSZombieEnabled, NSDeallocateZombies, NSHangOnUncaughtException, NSKeepAllocationStatistics: These values are not available from Python.
These functions are not available from Python.
PyObjC does not fully support running with the garbage collector enabled at the moment.
NSZeroPoint, NSZeroSize, NSZeroRect: these are mutable. Do not use them to initialize a variable that you’ll modify later on, use the default contructor instead.
This is, instead of:
point = NSZeroPoint # ... point.x = 4
point = NPoint() # ... point.x = 4
(or even: point = NSPoint(x=4)).
The CoreGraphics types CGPoint, CGSize and CGRect are interchangeable with their Foundation counterparts, there is no need to explicitly convert between them.
Struct NSObjCValue and related constants (such as NSObjCNoType) are not available in Python.
It is possible to get and set argument values and the return value of an invocation, but only for the simple cases, that is when the value is a single value and not a pointer to value or an array of values.
That is, the following methods cannot be accessed through an NSInvocation at the moment:
It is possible to get/set values whose type is a basic C type, that is the return value NSArray.count can be extracted from an NSInvocation object.
This limitation should be fine for most usecases of NSInvocation, please let us know if you run into cases where this limitation is a problem.
This class is only useable when the array is configured for Object use.
Accessing the actual function properties (such as hashFunction) is not supported.
Implementing or calling handleMachMessage: is not supported. The argument is mapped on a plain python integer, accessing the actual Mach message buffer is not possible.
The method initWithUUIDBytes: has an argument of type bytes with length 16.
The method getUUIDBytes: returns an instance of bytes of length 16.