objective c - resolveInstanceMethod with unknown number of arguments -
context:
i have dependency injection container - www.typhoonframework.org
it allows using interface defining components resolve them @ runtime - using resolveinstancemethod , implentationwithblock trampoline request di container.
users have been asking parameters provided @ runtime. example:
[assembly dangerousenemywithweapon:id<biggun>]
. . enemy assembled collaborating classes in di container, gun provided @ runtime. . .
the question:
is possible use resolveinstancemethod define implementation number of arguments not known front?
i package these arguments, , forward them on responder.
the arguments packed in order or added dictionary matching selector part key.
you can't use +resolveinstancemethod:
that, can use traditional forwarding. +resolveinstancemethod:
installs new instance method on class using objective-c runtime. don't affect how called. called other method arguments in registers , on stack caller supplied them. don't opportunity package or marshal arguments.
if implement -forwardinvocation:
, -methodsignatureforselector:
, nsinvocation
object. that's packaging of arguments (and return value). can use or interrogate unpack arguments , repack them how want.
Comments
Post a Comment