[Pyobjc-dev] Bundle loading hooks?
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-08-29 15:09:03
|
Hi, I'm one of the authors of PyObjC, which is a Python extension module that allows you to write Cocoa classes in Objective-C. This works pretty well for normal code, but we ran into a problem w.r.t. dynamicly loaded bundles (plugins) and the NSBundle methods 'classNamed:' and 'bundleForClass:'. When you define a subclass of an Objective-C class in Python, the PyObjC module automaticly creates a Objective-C class for you and registers that with the runtime. That is, it creates the right C datastructures and tells the runtime about these using objc_addClass and the like. As mentioned before, this works just fine, these classes can be used in NIB files and the classes are found using NSClassFromString. However, if you start querying with the NSBundle +bundleForClass:, all classes defined in Python seem to be defined in the main bundle even if they are actually defined in another (plug-in) bundle. Simularly, NSBundle -classNamed: will only find the class if you use the mainBundle. This is a problem for us, because this means Interface Builder cannot find the classes in a palette that has been defined in Python. Does anyone know a documented way to get the administration right? I got the IB palette working with a dirty hack: when the python plugin it loaded it looks for the NSBundle that is associated with its bundle and changes the 'isa' pointer of that NSBundle instance to a subclass of NSBundle that overrides classNamed. That doesn't look like the proper solution to me :-) Ronald |