[Pyobjc-dev] Suggested Documentation change
Brought to you by:
ronaldoussoren
From: Pierce T. W. I. <pi...@ma...> - 2003-08-13 17:51:09
|
Currently: The basics The code for loading a framework and exporting its classes is pretty simple: import objc objc.loadBundle("MyFramework", globals(), bundle_path='/path/to/MyFramework.framework') del objc If your class library does not require helper functions for some methods this is all that is needed. Don't forget to import the frameworks that are used by your framework before calling objc.loadBundle. This is necessary to arrange for the helper code for these modules (if there is any) to be loaded. Change to: The basics The code for loading a framework and exporting its classes is pretty simple: import objc objc.loadBundle("MyFramework", globals(), bundle_path='/path/to/MyFramework.framework') del objc However, in general, you don't want to use this, because its tedious to cut/paste this code everywhere. Instead, you can make this look just like a python module as follows: 1. Make a directory called "MyFramework" 2. in this directory create a file named __init__.py 3. Put the code above into that file. You can now import/load your framework via: import MyFramework example=MyFramework.MyObject.alloc().init() or from MyFramework import MyObject example=MyObject.alloc().init() If your class library does not require helper functions for some methods this is all that is needed. Don't forget to import the frameworks that are used by your framework before calling objc.loadBundle. This is necessary to arrange for the helper code for these modules (if there is any) to be loaded. Pierce P.S. I'm not sure about the: "Don't forget to import the frameworks that are used by your framework before calling objc.loadBundle." line. I did a quick test and found out that the framework loading mechanism seemed to be able to figure it out even if I didn't load all the required frameworks. It used to be true under Rhapsody, but X seems to have fixed this. |