[Pyobjc-dev] Question on Bridging/Integration
Brought to you by:
ronaldoussoren
From: Vincent <mai...@sa...> - 2012-05-20 20:25:28
|
Hi there, I'm new the whole PyObjC thing and have a simple document-bases app for which my goal is to all the user (personal project, so actually just me :P) to provide his/her (my) own filtering logic on a per-document basis. I basically have an NSSet of objects which need to be filtered based on a user-provided logic. As the logic should not be limited to rather primitive NSPredicates I'd like to provide a barebones in-app Python editor in which the user can define his/her logic. From what I've found on the web so far I know that one can subclass one's own Objective-C classes from inside Python using "objc.lookUpClass(…)". There is however still one question that remained unanswered: Being able to instantiate an Objective-C object from Python is neat, but still isolated. How do I expose a particular object instance from one language to the other? After all I need to pass my Objective-C object to Python for evaluation and receive an answer from it in respose. A minimal sample function (as provided by the user at runtime) would look something like this: def shallRejectObject(object) if object.foo(): return True return False Being totally new to PyObjC I'm thinking of some kind of reverse "objc.lookUpClass(…)" to allow me to instantiate my Python subclass from within Objective-C. Or how else would one approach this? Any hints? Thanks in advance, Vincent |