They seem to accomplish the same thing in Objective C. What can one do without the other?
Asked
Active
Viewed 783 times
1 Answers
3
For example:
- Delegate methods can have return values.
- There can be multiple targets for the same action, but usually only one delegate.
- The target-action mechanism is (semantically, not strictly) bound to predefined control events such as "value changed", "touch up", etc. Delegate methods can be anything.
- Delegate methods can have arbitrary arguments. Action methods always have the same arguments (sender and event, both optional).

Ole Begemann
- 135,006
- 31
- 278
- 256
-
Then why need IBAction at all? Why not always use delegate, like VB.net? Hmm... vb.net sort of only have IBAction isn't it? – user4951 Apr 25 '11 at 14:44
-
It's not a question of "need", it's a question of semantics. The target-action pattern fits better for predefined events (as mentioned above); the delegate pattern fits better for more complex relationships. – Ole Begemann Apr 25 '11 at 14:47