The Cocoa Way

Posted by admin under App Development on Wednesday Oct 21, 2009

You know its quite a mindset change doing things with the Cocoa Touch SDK. I’m a conventional OO programmer where I simply subclass an object with the required functionality and then add my own getters/setters and class methods. Cocoa is slightly different in that it uses delegates and protocols. You simply create an instance of an existing object and then you either implement a delegate method or you don’t. So for instance UITableView is the main UI component for rendering a table. So you create an instance of UITableView which on its own will do nothing. You need to tell the instance you are implementing a protocol, say for instance, UITableViewDatasource and then the instance will expect you to implement delegate methods as defined by UITableViewDatasource (if that makes sense!) which bind the table view to data.

Typically in my Win32 development days it would be a case of dropping a datasource onto a form, hooking it to a database and then hooking a datatable or query upto the datasource and then hooking the UI controls to the datatable.

ADD COMMENTS | Tags :