Package pycocoa
[frames] | no frames]

Package pycocoa

A basic, partial, ctypes-based Python binding to the macOS Objective-C Cocoa runtime and several other macOS libraries.

This is the cocoa-python package by Phillip Nguyen (C) 2011, modified, extended, tested, documented and published under the original New BSD License and the MIT License.

In addition to the pycocoa package, the distribution files contain several tests, examples and documentation (generated by Epydoc using command line: epydoc --html --no-private --no-source --name=PyCocoa --url=... -v pycocoa).

The example simple_VLCplayer.py requires installation of the VLC App for macOS and the corresponging Python-VLC binding.

The tests and examples have only been run with 64-bit Python 2.7.14 and 3.6.4 (with VLC 2.2.6 and 3.0.1) and only on macOS 10.13.3 High Sierra.

All PyCocoa source code has been statically checked with PyChecker, PyFlakes, PyCodeStyle (formerly Pep8) and McCabe using 64-bit Python 2.7.14 and with Flake8 on 64-bit Python 3.6.4.

To install PyCocoa, type pip install PyCocoa or easy_install PyCocoa in a terminal window. Alternatively, download PyCocoa- from PyPI or GitHub, unzip the downloaded file, cd to directory PyCocoa- and type python setup.py install. To run the PyCocoa tests, type python setup.py test before installation.

Two alternatives to PyCocoa are (a) PyObjC, the most comprehensive Python to Objective-C bridge and (b) Rubicon-ObjC for Python 3.5+, taking advantage of Python's new typing annotations.

__

Copyright (C) 2011 -- Phillip Nguyen -- All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of objective-ctypes nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

__

Copyright (C) 2017-2018 -- mrJean1 at Gmail dot com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Version: 18.03.15

Submodules

Classes
  CFAllocatorRef
  CFArray
  CFIndex
  CFNumberType
  CFRange
ObjC struct with location and length (CFIndex-s).
  CFString
Create a CFString instance for a Python string.
  CFStringEncoding
  CFTypeID
  CGBitmapInfo
  CGDirectDisplayID
  CGError
  CGFloat
  CGGlyph
  CGPoint
ObjC struct with x and y.
  CGRect
ObjC struc with origin and size.
  CGSize
ObjC struct with width and height.
  CTFontOrientation
  CTFontSymbolicTraits
  NSDecimalNumber
Optimized NSDecimalNumber class.
  NSInteger
  NSPoint
ObjC struct with x and y.
  NSRange
ObjC struct with location and length (NSInteger-s).
  NSRect
ObjC struc with origin and size.
  NSSize
ObjC struct with width and height.
  NSString
Auto-released version of the CFString class.
  NSTimeInterval
  NSUInteger
  ObjCBoundMethod
Python wrapper for an Objective-C method (an IMP) which has been bound to some Id which is passed as the first method argument.
  ObjCClass
Python wrapper for an Objective-C class.
  ObjCInstance
Python wrapper for an Objective-C instance.
  ObjCMethod
This represents an unbound Objective-C method (really an IMP).
  ObjCSubclass
Use this to create a subclass of an existing Objective-C class.
  UniChar
  at
Acronym for the NSString class.
  unichar
Functions
 
abspath(path)
Return an absolute path.
 
dirname(p)
Returns the directory component of a pathname
 
NSLog(fmt, *args)
Formatted write to the console.
 
NSMakePoint(x, y)
Return an NSPoint instance for the given x and y.
 
NSMakeRect(x, y, w, h)
Return an NSRect instance for the given point and size.
 
NSMakeSize(w, h)
Return an NSSize instance for the given w and h.
 
add_ivar(cls, name, ctype)
Add an instance variable to an Objective-C class, see also DeallocObserver below.
 
add_method(cls, selName, method, signature)
Add a method to an Objective-C class.
 
add_subclass(supercls, name, register=False, **ivars)
Create a new sub-class of the given super-class.
 
get_cfunctype(signature, codes=None)
Get the ctypes function type for a given signature type encoding.
 
get_class(name)
Get a registered Objective-C class by name.
 
get_classes(*prefixes)
Yield all loaded Objective-C classes with a name starting with one of the given prefixes.
 
get_classname(cls)
Get the name of an Objective-C class.
 
get_classof(obj)
Get the Objective-C class of an object.
 
get_inheritance(cls)
Yield the inheritance of an Objective-C class in bottom-up order.
 
get_ivar(obj, name, ctype=None)
Get the value of an instance variable.
 
get_ivars(cls, *prefixes)
Yield all instance variables of an Objective-C class with a name starting with one of the given prefixes.
 
get_lib(name)
Find and load the .dylib library.
 
get_metaclass(name)
Get a registered Objective-C metaclass by name.
 
get_method(cls, name)
Get a method of an Objective-C class by name.
 
get_methods(cls, *prefixes)
Yield all methods of an Objective-C class with a name starting with one of the given prefixes.
 
get_properties(cls_or_proto, *prefixes)
Yield all properties of an Objective-C class or protocol with a name starting with one of the given prefixes.
 
get_protocol(name)
Get a registered Objective-C protocol by name.
 
get_protocols(cls, *prefixes)
Yield all protocols of an Objective-C class with a name starting with one of the given prefixes.
 
get_selector(name)
Get an Objective-C selector (cmd) by name.
 
get_superclassof(obj)
Get the Objective-C superclass of an object.
 
isClass(obj)
Return True if the Objective-C object is a class.
 
isInstanceOf(obj, *Classes, **c_types)
Return True if the Objective-C object is an instance of any of the given Objective-C classes.
 
isMetaClass(obj)
Return True if the Objective-C object is a metaclass.
 
leaked2()
Return the number of memory leaks and the total number of bytes leaked.
 
ns2py(nsObj, default=None)
Convert an (instance of an) NS/CFObject to the equivalent Python type and value.
 
nsArray2listuple(nsArray, ctype=<class 'ctypes.c_void_p'>)
Create a Python list or tuple from an NS/CFArray.
 
nsBoolean2bool(nsBool, default=None)
Create a Python bool from an NS/CFBoolean.
 
nsData2bytes(nsData, default='')
Create Python bytes from NS/CFData.
 
nsDecimalNumber2decimal(nsDecimal)
Create a Python Decimal from an NS/CFDecimalNumber.
 
nsDictionary2dict(nsDict, ctype_keys=<class 'ctypes.c_void_p'>, ctype_vals=<class 'ctypes.c_void_p'>)
Create a Python dict from an NS/CFDictionary.
 
nsNull2none(nsNull)
Creat Python None from an NS/CFNull.
 
nsNumber2num(nsNumber, default=None)
Create a Python decimal, int or float from an NS/CFNumber.
 
nsSet2set(nsSet, ctype=<class 'ctypes.c_void_p'>)
Create a Python set or frozenset from an NS/CFSet.
 
nsString2str(nsString, default=None)
Create a Python string or unicode from an NS/CFString.
 
py2NS(pyobj)
Convert an (instance of a) Python object into an instance of an NS...
 
register_subclass(subcls)
Register an Objective-C subclass, see also DeallocObserver below.
 
send_message(receiver, selName, *args, **resargtypes)
Send message to the given receiver.
 
send_super(receiver, selName, *args, **resargtypes)
Send message to the superclass of the given receiver.
 
set_ivar(obj, name, value, ctype=None)
Set an instance variable of an Objective-C object to the given value.
 
split_emcoding2(encoding, start=0)
Split the type encoding of a method signature into separate, single encodings and the combined encoding.
 
split_encoding(encoding)
Split a type encoding into separate type encodings.
Variables
  NSUsualWindowMask = 15
  CGFloatEncoding = 'd'
  CGImageEncoding = '{CGImage=}'
  NSAlphaShiftKeyMask = 65536
  NSAlternateKeyMask = 524288
  NSAnyEventMask = 4294967295
  NSApplication = <ObjCClass NSApplication at 140735626076272>
  NSApplicationActivationPolicyAccessory = 1
  NSApplicationActivationPolicyProhibited = 2
  NSApplicationActivationPolicyRegular = 0
  NSApplicationDefined = 15
  NSApplicationDidHideNotification = c_void_p(140735622819760)
  NSApplicationDidUnhideNotification = c_void_p(140735622819856)
  NSApplicationPresentationDefault = 0
  NSApplicationPresentationDisableHideApplication = 256
  NSApplicationPresentationDisableProcessSwitching = 32
  NSApplicationPresentationHideDock = 2
  NSApplicationPresentationHideMenuBar = 8
  NSArray = <ObjCClass NSArray at 140735632965600>
  NSAutoreleasePool = <ObjCClass NSAutoreleasePool at 1407356375...
  NSBackingStoreBuffered = 2
  NSBackingStoreNonretained = 1
  NSBackingStoreRetained = 0
  NSBeginFunctionKey = 63274
  NSBezierPath = <ObjCClass NSBezierPath at 140735626076552>
  NSBorderlessWindowMask = 0
  NSClosableWindowMask = 2
  NSColor = <ObjCClass NSColor at 140735626078472>
  NSCommandKeyMask = 1048576
  NSControlKeyMask = 262144
  NSData = <ObjCClass NSData at 140735632965800>
  NSDecimalNumber_ = <ObjCClass NSDecimalNumber at 140735637589320>
  NSDefaultRunLoopMode = c_void_p(140735631966584)
  NSDeleteFunctionKey = 63272
  NSDictionary = <ObjCClass NSDictionary at 140735632965920>
  NSEndFunctionKey = 63275
  NSEnumerator = <ObjCClass NSEnumerator at 140735632965960>
  NSEventTrackingRunLoopMode = c_void_p(140735622814448)
  NSFlagsChanged = 12
  NSFunctionKeyMask = 8388608
  NSHelpKeyMask = 4194304
  NSHomeFunctionKey = 63273
  NSImage = <ObjCClass NSImage at 140735626005792>
  NSInsertFunctionKey = 63271
  NSIntegerEncoding = 'q'
  NSKeyDown = 10
  NSKeyUp = 11
  NSMenu = <ObjCClass NSMenu at 140735626007472>
  NSMenuItem = <ObjCClass NSMenuItem at 140735626007552>
  NSMiniaturizableWindowMask = 4
  NSMutableArray = <ObjCClass NSMutableArray at 140735632966240>
  NSMutableData = <ObjCClass NSMutableData at 140735632966280>
  NSMutableDictionary = <ObjCClass NSMutableDictionary at 140735...
  NSMutableSet = <ObjCClass NSMutableSet at 140735632966400>
  NSMutableString = <ObjCClass NSMutableString at 140735637593680>
  NSNull = <ObjCClass NSNull at 140735632966440>
  NSNumber = <ObjCClass NSNumber at 140735637593960>
  NSNumericPadKeyMask = 2097152
  NSObject = <ObjCClass NSObject at 140735736934720>
  NSOpenGLCPSwapInterval = 222
  NSOpenGLPFAAccelerated = 73
  NSOpenGLPFAAcceleratedCompute = 97
  NSOpenGLPFAAccumSize = 14
  NSOpenGLPFAAllRenderers = 1
  NSOpenGLPFAAllowOfflineRenderers = 96
  NSOpenGLPFAAlphaSize = 11
  NSOpenGLPFAAuxBuffers = 7
  NSOpenGLPFAAuxDepthStencil = 57
  NSOpenGLPFABackingStore = 76
  NSOpenGLPFAClosestPolicy = 74
  NSOpenGLPFAColorFloat = 58
  NSOpenGLPFAColorSize = 8
  NSOpenGLPFACompliant = 83
  NSOpenGLPFADepthSize = 12
  NSOpenGLPFADoubleBuffer = 5
  NSOpenGLPFAFullScreen = 54
  NSOpenGLPFAMPSafe = 78
  NSOpenGLPFAMaximumPolicy = 52
  NSOpenGLPFAMinimumPolicy = 51
  NSOpenGLPFAMultiScreen = 81
  NSOpenGLPFAMultisample = 59
  NSOpenGLPFANoRecovery = 72
  NSOpenGLPFAOffScreen = 53
  NSOpenGLPFAPixelBuffer = 90
  NSOpenGLPFARemotePixelBuffer = 91
  NSOpenGLPFARendererID = 70
  NSOpenGLPFARobust = 75
  NSOpenGLPFASampleAlpha = 61
  NSOpenGLPFASampleBuffers = 55
  NSOpenGLPFASamples = 56
  NSOpenGLPFAScreenMask = 84
  NSOpenGLPFASingleRenderer = 71
  NSOpenGLPFAStencilSize = 13
  NSOpenGLPFAStereo = 6
  NSOpenGLPFASupersample = 60
  NSOpenGLPFAVirtualScreenCount = 128
  NSOpenGLPFAWindow = 80
  NSOpenPanel = <ObjCClass NSOpenPanel at 140735626011912>
  NSPageDownFunctionKey = 63277
  NSPageUpFunctionKey = 63276
  NSPointEncoding = '{CGPoint=dd}'
  NSRangeEncoding = '{_NSRange=QQ}'
  NSRectEncoding = '{CGRect={CGPoint=dd}{CGSize=dd}}'
  NSResizableWindowMask = 8
  NSScreen = <ObjCClass NSScreen at 140735626015832>
  NSSet = <ObjCClass NSSet at 140735632966600>
  NSShiftKeyMask = 131072
  NSSizeEncoding = '{CGSize=dd}'
  NSSquareStatusItemLength = -2
  NSStatusBar = <ObjCClass NSStatusBar at 140735626018792>
  NSString_ = <ObjCClass NSString at 140735637597800>
  NSThread = <ObjCClass NSThread at 140735637598160>
  NSTitledWindowMask = 1
  NSTrackingActiveInActiveApp = 64
  NSTrackingCursorUpdate = 4
  NSTrackingMouseEnteredAndExited = 1
  NSTrackingMouseMoved = 2
  NSUIntegerEncoding = 'Q'
  NSURL = <ObjCClass NSURL at 140735632966880>
  NSUtilityWindowMask = 16
  NSVariableStatusItemLength = -1
  NSView = <ObjCClass NSView at 140735626025032>
  NSWindow = <ObjCClass NSWindow at 140735626025592>
  NSZeroPoint = NSPoint(0, 0)
  NSZoneEncoding = '{_NSZone=}'
  OBJC_ASSOCIATION_COPY = 771
  OBJC_ASSOCIATION_COPY_NONATOMIC = 3
  OBJC_ASSOCIATION_RETAIN = 769
  OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1
  PyObjectEncoding = '{PyObject=@}'
  kCFAllocatorDefault = c_void_p(None)
  kCFRunLoopDefaultMode = c_void_p(140735631966584)
  kCFStringEncodingASCII = 1536
  kCFStringEncodingISOLatin1 = 513
  kCFStringEncodingMacRoman = 0
  kCFStringEncodingNonLossyASCII = 3071
  kCFStringEncodingUTF16 = 256
  kCFStringEncodingUTF16BE = 268435712
  kCFStringEncodingUTF16LE = 335544576
  kCFStringEncodingUTF32 = 201326848
  kCFStringEncodingUTF32BE = 402653440
  kCFStringEncodingUTF32LE = 469762304
  kCFStringEncodingUTF8 = 134217984
  kCFStringEncodingUnicode = 256
  kCFStringEncodingWindowsLatin1 = 1280
  kCGBitmapAlphaInfoMask = 31
  kCGBitmapByteOrder16Big = 12288
  kCGBitmapByteOrder16Little = 4096
  kCGBitmapByteOrder32Big = 16384
  kCGBitmapByteOrder32Little = 8192
  kCGBitmapByteOrderDefault = 0
  kCGBitmapByteOrderMask = 28672
  kCGBitmapFloatComponents = 256
  kCGImageAlphaFirst = 4
  kCGImageAlphaLast = 3
  kCGImageAlphaNone = 0
  kCGImageAlphaNoneSkipFirst = 6
  kCGImageAlphaNoneSkipLast = 5
  kCGImageAlphaOnly = 7
  kCGImageAlphaPremultipliedFirst = 2
  kCGImageAlphaPremultipliedLast = 1
  kCGImagePropertyGIFDelayTime = c_void_p(140735638804776)
  kCGImagePropertyGIFDictionary = c_void_p(140735638801288)
  kCGRenderingIntentDefault = 0
  kCTFontAttributeName = c_void_p(140735635398032)
  kCTFontBoldTrait = 2
  kCTFontFamilyNameAttribute = c_void_p(140735635422928)
  kCTFontItalicTrait = 1
  kCTFontSymbolicTrait = c_void_p(140735635362864)
  kCTFontTraitsAttribute = c_void_p(140735635423056)
  kCTFontWeightTrait = c_void_p(140735635362896)
Function Details

add_ivar(cls, name, ctype)

 

Add an instance variable to an Objective-C class, see also DeallocObserver below.

The ctype must be a ctypes type or a valid Objective-C type encoding as bytes.

add_method(cls, selName, method, signature)

 

Add a method to an Objective-C class.

The signature is the type encoding for the result and arguments of the method callable.

add_subclass(supercls, name, register=False, **ivars)

 

Create a new sub-class of the given super-class.

After calling add_subclass, you must register the new class with register_subclass and before using the new class.

New methods can be added after the class has been registered, but any ivars must be added before the class is registrated.

Or, use keyword argument register=True to register the class and specify any number of instance variables to be added as keyword arguments ivarname=ctype.

get_cfunctype(signature, codes=None)

 

Get the ctypes function type for a given signature type encoding.

Limited to basic type encodings and pointers to basic type encodings and does not handle arrays, bitfiels, arbitrary structs and unions.

The signature is a bytes object and not unicode and codes is a list of the individual type encodings. If codes is not supplied, it will be created by split_encoding the signature (not split_emcoding2).

get_classes(*prefixes)

 

Yield all loaded Objective-C classes with a name starting with one of the given prefixes.

For each class yield a 2-tuple (name, class) where name is the class name and class is the Objective-C class object.

get_ivars(cls, *prefixes)

 

Yield all instance variables of an Objective-C class with a name starting with one of the given prefixes.

For each ivar yield a 4-tuple (name, encoding, ctype, ivar) where name is the ivar name, encoding is the ivar's type encoding, ctype is the ivar's ctypes type and ivar the Ivar object.

get_methods(cls, *prefixes)

 

Yield all methods of an Objective-C class with a name starting with one of the given prefixes.

For each method yield a 4-tuple (name, encoding, rargtypes, method), where name is the method name, encoding is the type encoding of the method signature including the return type, rargtypes the ctypes signature, the argtypes list** preceeded by the restype and method the Method object.

**) In Python 3+ rargtypes is a map object, not a list.

get_properties(cls_or_proto, *prefixes)

 

Yield all properties of an Objective-C class or protocol with a name starting with one of the given prefixes.

For each property, yield a 3-tuple (name, attributes, setter, property) where attributes is a comma-separated list of the property attibutes, setter is the name of the property setter method, provided the property is writable and property is the Property object. The setter is an empty name '' for read-only properties.

Objective-C Property Attributes:

  • T<type>"name" = Type
  • & = Retain last value (retain)
  • C = Copy
  • D = Dynamic (@dynamic)
  • G<name> = Getter selector name
  • N = Non-atomic (nonatomic)
  • P = To be garbage collected
  • R = Read-only (readonly)
  • S<name> = Setter selector name
  • t<encoding> = Old-dtyle type encoding
  • W = Weak reference (__weak)

See Property Attributes.

get_protocols(cls, *prefixes)

 

Yield all protocols of an Objective-C class with a name starting with one of the given prefixes.

For each protocol, yield a 2-tuple (name, protocol) where name is the protocol name and protocol the Protocol object.

ns2py(nsObj, default=None)

 

Convert an (instance of an) NS/CFObject to the equivalent Python type and value.

  • NSArray -> tuple
  • NSBoolean -> bool
  • NSData -> bytes
  • NSDecimalNumber -> Decimal
  • NSDictionary -> dict
  • NSMutableArray -> list
  • NSMutableSet -> set
  • NSMutableString -> str
  • NSNumber -> int or float
  • NSNull -> None
  • NSSet -> frozenset
  • NSString -> str

py2NS(pyobj)

 

Convert an (instance of a) Python object into an instance of an NS... Objective-C class as follows:

  • bool -> NSBoolean/NSNumber
  • bytes -> NSData
  • bytearray -> NSData
  • Decimal -> NSDecimalNumber
  • dict -> NSMutableDictionary
  • float -> NSNumber
  • frozenset -> NSSet, immutable
  • int -> NSNumber
  • list -> NSMutableArray
  • None -> NSNull
  • set -> NSMutableSet
  • str -> NSString, immutable
  • tuple -> NSArray, immutable
  • unicode -> NSString, immutable

send_message(receiver, selName, *args, **resargtypes)

 

Send message to the given receiver.

By default, the result and all arguments are c_void_p wrapped.

Use keyword arguments restype=c_void_p and argtypes=[] to change the defaults. The restype defines the ctypes type for the returned result and argtypes is the list of ctypes types for the message arguments only (without the id/self and self/cmd arguments).

send_super(receiver, selName, *args, **resargtypes)

 

Send message to the superclass of the given receiver.

By default, the result and all arguments are c_void_p wrapped.

Use keyword arguments restype=c_void_p and argtypes=[] to change the defaults. The restype defines the ctypes type for the returned result and argtypes is the list of ctypes types for the message arguments only (without the id/self and self/cmd arguments).

split_emcoding2(encoding, start=0)

 

Split the type encoding of a method signature into separate, single encodings and the combined encoding.

If necessary, the encoding is extended with the type encoding for the hidden method arguments id/self and SEL/cmd.

Does not handle bitfields, arrays, structs, unions, etc. and strips any offset, size or width specifiers from the encoding.

In the returned 2-tuple (codes, encoding), codes is the list of individual type encodings from item start=0 and encoding the combined type encoding in bytes and both extended if needed.

Example:

>>> split_emcoding2('v*')
>>> (['v', '@', ':', '*'], 'v@:*')

split_encoding(encoding)

 

Split a type encoding into separate type encodings.

Does not handle bitfields, arrays, structs, unions, etc. and strips any offset, size or width specifiers from the encoding.

Examples:

>>> split_encoding('^v16@0:8')
>>> ['^v', '@', ':']
>>> split_encoding('{CGSize=dd}40@0:8{PyObject=@}Q32')
>>> ['{CGSize=dd}', '@', ':', '{PyObject=@}', 'Q']

Supported Type Encodings:

  • B = bool (C++ bool, C99 _Bool)
  • c, C = char, unsigned char
  • f, d = float, double
  • i, I = int, unsigned int
  • l, L = long, unsigned long (32-bit)
  • q, Q = long long, unsigned long long
  • s, S = short, unsigned short
  • t, T = 128-bit int, unsigned int
  • v = void
  • * = string (char *)
  • : = method selector (SEL/cmd)
  • # = class
  • #"name" = class "name"
  • @ = object (instance, statically typed, typed id, etc.)
  • @"name" = instance of class "name"
  • ^type = pointer to type
  • ? = unknown type (among other things, used for function pointers)

Unsupported Type Encodings:

  • bW = bit field of width W
  • [Ltype] = array of L items of type
  • {name=type...} = structure
  • (name=type...) = union
  • <...> = block

For Objective-C internal use only:

  • n, N = in, inout
  • o, O = out, bycopy
  • r, R = const, byref
  • V = oneway

Type encodings may be preceeded by a "name", for example a bit field "name"b1, structure fields {CGsize="width"d"heigth"d}, union items, etc. and all such "name" prefixes are ignored. See also Type Encodings, NSHipster Type Encodings and Digits in type encoding.


Variables Details

NSAutoreleasePool

Value:
<ObjCClass NSAutoreleasePool at 140735637587560>

NSMutableDictionary

Value:
<ObjCClass NSMutableDictionary at 140735632966320>