Actions in Objective C and Swift
One way that Cocoa implements callbacks using Actions in the Interface Builder. Some display objects can call actions in your ViewController. You can connect the object to a method in your custom ViewController class by control dragging from the object to a class, and selecting ‘Action’. You can then choose the action(if there is more than one action available) and name the method in your code to call. It will then highlight that this method is connected to an item in the Interface Builder with the keyword IBAction and a filled circle. You can see the actions defined for an object in the Connections Inspector.
Objective C:
- (IBAction)didTapButton:(id)sender { }
Swift:
@IBAction func didTapButton(sender : AnyObject) { }
[…] Part 2: Actions […]
[…] Part 2: Actions […]