Right now I am using the delegate, but I suspect it's bad form.
I programatically create an identical UIBarButtonItem
in numerous, different view controllers.
My button's target is myAppDelegate
, and its action is defined therein.
What is a better way of doing this? Or am I just supposed to copy and paste the identical action into no-matter-how-many view controllers that instantiate the identical bar button?
Okay, now suppose the action is identical in all respects but one: It varies only in that it should send a presentViewController message to the view controller that instantiated the button that sent the action. Thus, in the action, I can send a presentViewController
message to sender
, which is an instance of the button, but I know no means of reaching the view controller that instantiated that instance of the button.