Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Invoking an NsBlock
-
Has anyone had success
invok
ing an NSBlock? I have a python objc class that i have crated, which is accepting an ObjCBlock as an argument. The Block takes two arguments, and integer and a pointer (to the objc equivalent of a list). (This is thecompletion
arg of for a PA2ConsoleCompletionProvider )However, when calling ObjCInstance on the pointer, it returns an NSBlock. This has a method invoke(), but it does not want to take arguments. I feel like I have ben able to do this before, but I have forgotton how!
-
To be clear -- the block i want to call is one provided to me, not one i created.
-
I don't know how well the
invoke
method works... I think the proper way to invoke a block is to read it as a structure pointer (see http://clang.llvm.org/docs/Block-ABI-Apple.html for the struct format), take theinvoke
function pointer from there, cast it to the correct signature, and then call that.