Re: [Pyobjc-dev] **NSError handling in PyObjC 2.2
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ron...@ma...> - 2009-06-30 11:34:34
|
On 26 Jun, 2009, at 16:05, Ian Beck wrote:
> Hey there,
>
> One of my users messaged me to let me know that my Cocoa plugin
> (written in Python using PyObjC with py2app) was failing to load on
> his machine. Turns out he was using PyObjC 2.2 beta 2, and it was
> dying because it wasn't handling an implicit **NSError argument.
> Here's the relevant Python code that was killing it:
>
> @objc.signature('B@:@')
> def performActionWithContext_error_(self, context):
>
> This function is defined by the program's protocol:
>
> - (BOOL)performActionWithContext:(id)context error:(NSError **)
> outError;
>
> Is PyObjC 2.2 no longer going to silently support **NSError
> parameters, or is this a known 2.2 bug?
In PyObjC 2.2 you have to specify all arguments that the ObjC method
gets, that includes output arguments like NSError. There are two
reasons for that: first of all this makes the interface more regular
and easier to learn, more importantly this enables new functionality:
you can now detect if the user wants the value (outError is None) or
not (ourError is objc.NULL).
Ronald
|