[Pythonmac-SIG] Calling a python objc class method from cocoa

Saptarshi Guha saptarshi.guha at gmail.com
Sun Oct 19 00:15:45 CEST 2008


Hello,
I have a mainly cocoa app which uses some Python modules.  I need to  
call a classmethod of a NSObject subclass written in
python from Cocoa
=Structure=

After loading the Python interpreter, i call this method

-(void)initialize
{
	Class pySocket = NSClassFromString(@"pySocket");
	NSLog(@"%@",pySocket);
	[pySocket setdefaulttimeout:10];
}

pySocket:

from Foundation import *
import socket
class pySocket(NSObject):
	#no init method right now, only want to run class methods
     @classmethod
     def setdefaulttimeout(cls,timeout):
         socket.setdefaulttimeout(timeout)

==Error==

I get the following error:
2008-10-18 17:48:14.227 argnostic[10697:10b] pySocket
2008-10-18 17:48:14.228 argnostic[10697:10b] *** +[pySocket  
setdefaulttimeout:]: unrecognized selector sent to class 0x3b33d0
2008-10-18 17:48:14.228 argnostic[10697:10b] *** +[pySocket  
setdefaulttimeout:]: unrecognized selector sent to class 0x3b33d0

How then do I call a Python NSObject subclasses classmethods from cocoa?
Thank you
Saptarshi


Saptarshi Guha | saptarshi.guha at gmail.com | http://www.stat.purdue.edu/~sguha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20081018/7085604f/attachment.htm>


More information about the Pythonmac-SIG mailing list