Re: Access ObjC class from PyOBJC
Re: Access ObjC class from PyOBJC
- Subject: Re: Access ObjC class from PyOBJC
- From: Bill Bumgarner <email@hidden>
- Date: Wed, 02 Jun 2010 14:24:36 -0700
On Jun 2, 2010, at 2:16 PM, email@hidden wrote:
> My app is ObjC cocoa based
>
> It also loads and executes PyObjC classes.
>
> I require my loaded PyObjC code to access an ObjC class (myControllerClass) defined within an ObjC framework linked to the main application.
>
> The desired Python looks something like:
>
> #py
> import AppKit
>
> taskController = myControllerClass.sharedController()
>
> #py
>
> Do I need to define a py wrapper from my framework and import it to accomplish this?
> And if so, how is the wrapper constructed.
>
> Or am I missing something simple here.
You don't need to define a wrapper or use bridge support metadata *unless* your class's API has methods whose arguments and types can't be handled by default (most can) *and* you need to call those from Python.
import Foundation
klass = Foundation.NSClassFromString("MyControllerClass")
controller = klass.new()
>
> Regards
>
> Jonathan Mitchell
>
> Developer
> Mugginsoft LLP
> http://www.mugginsoft.com
>
>
>
>
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden