How can I use return in my objC class
from objc_util import * def foo_bar(_self,_cmd): baz = c_int() return baz foo=create_objc_class('foo',methods=[foo_bar]) foo = foo.alloc() foo.bar.restype = c_int print('out',foo.bar())
I couldn’t found what I have to do.
Please teach me.
first, you need to call .alloc().init(). well, in this case you don't, but if you send this object to other objc code it will crash if you dont,
second, you need to set encoding, and optionally restype, AND argtypes. (restype only works if argtypes is also specified). This must be done before you call create_objc_class. Most import is the encoding.
Also, you just return normal python types, and the callback mechanism takes care of converting.
Here is you code, updated, along with a description of the type encodings. see objc_util source for more details