I have block of unknown type (as id) and array of arguments that need to passed into that block. Arguments may be objects or numbers/structs boxed as NSNumber/NSValue. Block may also return an object, number or struct. This is a library code, and types of arguments are not known beforehand.
Assuming that I can can dynamically read signature from the block descriptor, is there a way to construct something like an NSInvocation to call a block?
Surprisingly this works:
But on the other hand, this does not:
AFAICS from the disassembly, implementation of the
[NSInvocation invoke]checks for the class of the target, and if it is a block (subclass ofNSBlock) then it always calls block function, regardless of the signature.Updated: Reported as rdar://25289979