Posted on Leave a comment

5 ways to do the callbacks in objective C and iOS dev

Reading Time: < 1 minute

1. Selector

An example
[button addTarget:yourObject action:@selector(yourMethod:) forControlEvents:UIControlEventTouchUpInside];

2. NSNotifications
In a way (and in syntax too) it’s similar to Selector, but used in different settings.

example here

3. Delegate methods
e.g., UIAlert view, UITextField delegate

customized method (example)

4. Blocks


5. GCD
My favorite example here.

Combinations of some of the above, e.g, blocks (GCD) with notification

Leave a Reply

Your email address will not be published. Required fields are marked *