3 ms·
I've struggled through a few Cocoa tutorials. I think the programmer creates a delegate object which handles events. These delegates are assigned to UI elements
by teyc 15y ago
I've struggled through a few Cocoa tutorials. I think the programmer creates a delegate object which handles events. These delegates are assigned to UI elements, similar to how one would addMouseListener to a Java UI element. I may be entirely wrong here. Perhaps someone who knows can put the facts straight.
- hboon 15y agoUI 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.