Re: [Pyobjc-dev] How to get Python class into Objc namespace
Brought to you by:
ronaldoussoren
|
From: Bill B. <bb...@ma...> - 2008-05-09 01:45:13
|
On May 8, 2008, at 5:38 PM, Steve Steiner wrote: > If someone will just point me to the right resource, I'll blog it and > make it findable by the next poor sot. [[NSClassFromString(@"MyPythonClass") alloc] init]; Your challenge will be where you define the method prototypes to keep the compiler happy. Personally, I would create a dummy class that has NO methods, then declare categories against that dummy class that has all of the methods w/appropriate signature that are needed... then declare the result of the above to be a pointer to an instance of that class. Makes the compiler happy and the runtime doesn't care. Unless you are jumping through hoops to declare the method signatures, everything will be of an object type. If you want to provide subclasses of specific objc classes that are implemented in python, then declare an abstract subclass that contains all the method declarations and implementations that do nothing, then subclass that from Python. That'll give the bridge all (if you run gen_bridge_metadata, if needed) to do the conversions across the bridge for the types that need it. b.bum |