I am trying to press a UIBarButtonItem and perform an action, which it does. When It does I'm changing the name of the title of the BarButtonItem. That way if I hit it again I want to Undo the action it performed rather than coding everything out to change it back. Here is an example of my code.
- (IBAction)MyAction:(id)sender{
if([[MyButton title] isEqualToString:@"Test1"]){
//My Action is performed.
[MyButton setTitle:@"Test2"];
[[undoManager prepareWithInvocationTarget:self] MyAction:?];
[undoManager setActionName:@"UndoLastAction"];
}else if ([[MyButton title] isEqualToString:@"Test2"]){
[MyButton setTitle:@"Test1"];
[[undoManager prepareWithInvocationTarget:self]MyAction:?];
[undoManager setActionName:@"UndoLastAction"];
}
}
Never mind, it's easier just to re-run the original code to "Undo" the action.