objective c - How does forwardingTargetForSelector: work? -


i have uibarbuttonitem. when receives message cannot handle, want forward message particular view controller.

i thought might able accomplish using bar button item's forwardingtargetforselector: method, apparently no such property found on objects of type uibarbuttonitem. (point of terminology: mean forwardingtargetforselector: private property? edit: wait, think i'm confused... methods colon @ end aren't properties... can ever make public method (like getter/setter) parameters passed?)

and mean in order set value of forwardingtargetforselector: must within .m file of object want set it? mean have subclass uibarbuttonitem?

and if so, why not public property of nsobjects?

and moreover, what's best way achieve forwarding goal, preferably avoiding subclassing?

additional information:

it stems inclination reuse single action in response various instances of identical button being pressed. action contained in delegate (see how should implement [almost] identical actions used throughout various vcs? (answer: use category)) , varies in should send presentviewcontroller message view controller instantiated button sent action. thus, in action, can send presentviewcontroller message sender, instance of button, , want able forward message view controller created instance of button, can if set each button's forwarding property after instantiated in respective view controller.

i hoped avoid "why" make question shorter, there ya go.

forwardingtargetforselector: not property; it's more question runtime asks instance when instance doesn't respond message.

it can't property in @property/ sense, because each selector have different target; there need mapping behind it. that's not how declared properties work.

uibarbuttonitem descends nsobject, , inherits method along others, can't "set" forwarding target selector outside instance (without creating other machinery allow so, anyways -- possible, not available default).

in order utilize method, yes, have implement in class doing forwarding. indeed mean subclassing. means forwarding instance needs have reference object forwarding; requires careful design.

forwardingtargetforselector: not correct way achieve whatever goal is. in general, in fact, it's bit esoteric.

i'm not sure problem you're trying solve ("making button forward messages doesn't respond to" still rather general -- in particular, why necessary?), it's hard more precise.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -