Re: [Pyobjc-dev] Accessing python classes in obj-c
Brought to you by:
ronaldoussoren
From: Jiva D. <ji...@de...> - 2004-01-05 07:06:52
|
On Dec 8, 2003, at 2:09 PM, b.bum wrote: > On Dec 8, 2003, at 12:17 PM, Jiva DeVoe wrote: >> So I understand that I can create Python files and the templates >> supplied with PyObjC automatically will load those Python files and >> do what ever I want them to. I also understand if I instantiate a >> python class in python, and access it in obj-c, I will get a proxy >> object to the python object. However, what if I have an objective-c >> application, and I want to write a portion of it in python. So, in >> other words, I want to be able to create a class in Python, and >> instantiate an object in objective-c that is of that class. How >> would I do that? Would I have to use something like SWIG? > > Compile time is a bit harder. In particular, you can't refer to any > class implemented in python directly because there won't be a real > class object to link against as the source is compiled. To solve > this problem, I have used an abstract superclass implemented in > Objective-C (a class that simply declares all the methods where the > implementation is stubbed out) and a concrete subclass implemented in > Python. To the abstract superclass-- the objc class-- I have added a > factory method that instantiates and returns the concrete subclass. > I know this is an old post, my apologies... just wanted a clarification. How do you instantiate the concrete subclass in the factory method without having the real class? Any pointers to some example code for this? -- Jiva DeVoe jiva at devoesquared.com http://www.devoesquared.com |