Subscribe
« Announcement: Project Empty Tome | Main | Breaking News: MonoTouch 1.2 with debugging released! (screenshots) »
Monday
Nov022009

UITableViewController (uitvc) template updated for UITableViewSource

MonoTouch 1.2 adds a new class called UITableViewSource that is intended to reduce some of the code clutter that is encountered when using TableViews in MonoTouch.  The UITableViewSource class combines UITableViewDelegate and UITableViewDataSource into one convenient class that contains the methods of both.  This results in a much closer approximation of the way the UIKit classes work.  In UIKit you would typically have your TableViewController implement the protocols for delegate and datasource and thus all of your methods from these two protocols would be in the same class.  The UITableViewSource class gives you a similar code structure.

I have modified the uitvc template for generating a UITableViewController that uses this new UITableViewSource class.  Create an Empty class file from the File->New File…->General menu.  Delete everything in this class file.  Type uitvc and hit the tab key. This will create a UITableViewController subclass that sets up a UITableViewSource as its Source.  All you need to do is specify the namespace for the controller, the name for your class, the shorthand that will be used to reference the instance of the controller in the UITableViewSource, and the Title for the controller.  I have provided a few overrides that will get you started after that.  You can download the template here: uitvc.template.xml

You will need to add this to ~/.config/MonoDevelop/templates/code (choose “Go to folder…” from the Finder menu and paste the directory to find it) and restart MonoDevelop. (Note: If you don’t see templates/code in ~/.config/MonoDevelop, go to Preferences in MonoDevelop and click on Code Templates under Coding.  This should populate this directory.  You don’t need to do anything else here, just close Preferences and follow the instructions above to add the file to the ~/.config/MonoDevelop/templates/code directory.)

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (7)

Thanks Brent, these templates are really useful.

November 2, 2009 | Unregistered CommenterAlex York

No prob Alex! I figured it was about time to update it since the UITableViewSource thing is pretty awesome.

November 2, 2009 | Registered Commenterbrentschooley

Thanks Brent, didn't know about these templates in monodevelop.

November 5, 2009 | Unregistered CommenterNik Smit

Thank you thank you!!!!

Would anymore be coming? This is AMAZINGLY helpful.

January 10, 2010 | Unregistered CommenterIan Vink

Just so you know. The link should be "http://www.codesnack.com/storage/templates" that way the user can copy the file instead of the code in the file which is of no help.


Great job! and Thank you
Adan

June 5, 2010 | Unregistered CommenterAdan

I like your site. It’s really simple and cool without no much of put ups. I am also going to design my site simple and nice as yours

Cheap Dental Health Insurance
Full Coverage Dental Insurance
Benefits of Affordable Dental Insurance

June 16, 2010 | Unregistered CommenterRajus

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>