3 ms·
UI elements typically gets assigned an instance of an object (target) and a symbol representing the object's method (selector). In Cocoa touch, it's: [myb
by hboon 15y ago
UI elements typically gets assigned an instance of an object (target) and a symbol representing the object's method (selector).
In Cocoa touch, it's:
[mybutton addTarget:someObjectMaybeSelf action:@selector(onClick) forControlEvents:UIControlEventTouchupInside];
It's broken into separate methods in Cocoa but it's similar. You don't need to and usually don't create separate classes for targets.
The framework usually use delegates when a data source is needed. (for example to build up a table, you need to specify how many rows, what goes into each row etc).
Cocoa touch is really clean. Cocoa is still nice but a little messy.