1================================================ 2:mod:`PyObjCTools.NibClassBuilder` -- Magic NIBs 3================================================ 4 5.. module:: PyObjCTools.NibClassBuilder 6 :synopsis: Extract definitions from NIBs 7 8.. deprecated:: 2.4 9 Use of this module is deprecated because it cannot be 10 used with modern versions of Xcode (starting at Xcode 4.0), 11 and because recent versions of Xcode can extract class 12 information from Python sources. 13 14 15Introduction 16------------ 17 18The module is used to avoid repeating class inheritance and outlet 19definitions in both python sources and Interface Builder NIB files. 20 21The module reads this information from NIB files and provides a magic 22meta class that inserts the right superclass and outlet definitions. 23 24Do not use this module for new developement, it will likely disappear 25in a future version of PyObjC because it can no longer work with modern 26versions of Xcode, and in particular not with XIB files and compiled 27NIB files. 28 29Extracting class definitions from nibs 30-------------------------------------- 31 32 33The module maintains a global set of class definitions, extracted from 34nibs. To add the classes from a nib to this set, use the ``extractClasses()`` 35function. It can be called in two ways: 36 37.. function:: extractClasses(nibName, bundle=<current-bundle>) 38 39 This finds the nib by name from a bundle. If no bundle 40 if given, the ``objc.currentBundle()`` is searched. 41 42.. function:: extractClasses(path=pathToNib) 43 44 This uses an explicit path to a nib. 45 46``extractClasses()`` can be called multiple times for the same bundle: the 47results are cached so no almost extra overhead is caused. 48 49Using the class definitions 50--------------------------- 51 52The module contains a "magic" base (super) class called ``AutoBaseClass``. 53Subclassing ``AutoBaseClass`` will invoke some magic that will look up the 54proper base class in the class definitions extracted from the nib(s). 55If you use multiple inheritance to use Cocoa's "informal protocols", 56you *must* list ``AutoBaseClass`` as the first base class. For example:: 57 58 class PyModel(AutoBaseClass, NSTableSource): 59 ... 60 61 62The ``NibInfo`` class 63--------------------- 64 65The parsing of nibs and collecting the class definition is done by the 66``NibInfo`` class. You normally don't use it directly, but it's here if you 67have special needs. 68 69The command line tool 70--------------------- 71 72When run from the command line, this module invokes a simple command 73line program, which you feed paths to nibs. This will print a Python 74template for all classes defined in the nib(s). For more documentation, 75see the commandline_doc variable, or simply run the program without 76arguments. It also contains a simple test program. 77