I have this code:
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:textField action:@selector(setText:)];
How do I send a piece of info with the setText action. For instance
setText:@"This is text"
Thank you.
Configured as an action
setText:will be called with an(id)senderwheresenderwill be yourUIButton. If you were using a custom UIButton you could give it a property to hold the text you wanted to pass and then access that within your action method. Since you’re usingUIBarButtonSystemItemDoneyou cannot.Let me guess what you want to do: let the user enter some text and pass that back to a parent view controller when they click done.
If so, try this:
setText:So…
I hope that helps.