I'm implementing an ObjC protocol as a mix-in for a PyObjC class.
This protocol defines an 'out' parameter.
I am unable to find any good documentation on how a Python class which implements an ObjC protocol defining this is to behave.
I've found this mailing list thread but the suggestion in there does not work. They say to return a Python list with the method's return value as the first item and the out parameter as the second.
I've tried this and all I get is an exception when calling from ObjC (<type 'exceptions.ValueError'>: depythonifying 'char', got 'tuple'
).
It seems PyObjC strictly adheres to the ObjC protocol in depythonifying method arguments, which is nice but it doesn't help me trying to modify an out parameter.
This is the ObjC protocol:
#import <Foundation/Foundation.h>
@protocol TestProtocol <NSObject>
- (BOOL)testMethod:(NSError **)error;
@end
This is the Python class implementing this protocol:
from Foundation import *
import objc
NSObject = objc.lookUpClass("NSObject")
TestProtocol = objc.protocolNamed("TestProtocol")
class TestClass(NSObject, TestProtocol):
def testMethod_(self, error):
return True, None
QUESTION: How do I return an ObjC out parameter in Python?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…