<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>IIrrelevant</title>
    <link>http://www.milkcarton.com/blog/</link>
    <description>Irrelevant musings about software development</description>
    <language>en-us</language>
    <copyright>Dan Morphis</copyright>
    <lastBuildDate>Mon, 25 Jul 2011 02:59:41 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>dan@milkcarton.com</managingEditor>
    <webMaster>dan@milkcarton.com</webMaster>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=6c743ae9-01c8-4c1b-a9c1-d6ce89f3294a</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,6c743ae9-01c8-4c1b-a9c1-d6ce89f3294a.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,6c743ae9-01c8-4c1b-a9c1-d6ce89f3294a.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=6c743ae9-01c8-4c1b-a9c1-d6ce89f3294a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve been using the <a href="http://www.galasoft.ch/mvvm/">MvvmLight Toolkit</a> on
a project now for several weeks. At first, the ViewModelLocator pattern the toolkit
uses didn’t bother me. But after you wonder why your view can’t be located and then
debug everything only to discover that you forgot to create the ViewModel in the ViewModelLocator.
</p>
        <p>
I first thought about switching the ViewModelLocator to inherit from <a href="http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject.aspx">DynamicObject</a> and
using <a href="http://mef.codeplex.com/">MEF</a> to discover the VIewModel’s. A quick
search lead me to discover that <a href="http://johnpapa.net/simple-viewmodel-locator-for-mvvm-the-patients-have-left-the-asylum">I’m
not</a><a href="http://rickrat.wordpress.com/2011/01/24/using-mef-to-link-view-model-locator-and-load-assembly-uis-dynamically/">the
only</a><a href="http://kellabyte.com/2010/08/25/use-mef-to-decouple-discovery-of-your-viewmodels-in-mvvmlights-viewmodellocator/">one</a> to
have that same thought <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.milkcarton.com/blog/content/binary/Windows-Live-Writer/7f91385d833f_FD78/wlEmoticon-smile_2.png" /></p>
        <p>
The one thing I didn’t like about using Dynamic and MEF for discovering the ViewModel
was the design time experience took a big hit. Locating the ViewModel was now much
more expensive at design time.
</p>
        <p>
I started started doing more thinking, and wondered if I could use <a href="http://msdn.microsoft.com/en-us/library/bb126445.aspx">T4</a> to
generate the ViewModelLocator for me. After more thought, I knew I had to be able
to use T4 to generate the ViewModelLocator, heck T4MVC uses it to generate a bunch
of helper classes.
</p>
        <p>
Because I’m big on using IoC in my apps, I’ve also added the ability to get the ViewModel
from an IoC container if the application isn’t in design mode.
</p>
        <p>
There are two files that are required to make this approach work. ViewModelLocator.tt,
and ViewModelLocator.settings.t4. The settings file exists so you can configure the
what’s and how’s. If you use the default setup for MvvmLight, the only thing you will
have to change is the IoC stuff.
</p>
        <p>
To use the T4 ViewModelLocator, delete your existing ViewModelLocator.cs class in
your ViewModel folder, and drop the two T4 files into your ViewModel folder. Once
that happens, you will see a new icon show up in the solution explorer called “Transform
All Templates.” Click that icon to have your ViewModelLocator automatically generated
for you, compile and run <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.milkcarton.com/blog/content/binary/Windows-Live-Writer/7f91385d833f_FD78/wlEmoticon-smile_2.png" /></p>
        <p>
          <a href="http://www.milkcarton.com/blog/content/binary/Windows-Live-Writer/7f91385d833f_FD78/image_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.milkcarton.com/blog/content/binary/Windows-Live-Writer/7f91385d833f_FD78/image_thumb.png" width="244" height="43" />
          </a>
        </p>
        <p>
          <a href="http://files.milkcarton.com/public/ViewModelLocator.zip">Download the T4
templates!</a>
        </p>
        <p>
Next time, I’ll write a post about using <a href="http://mef.codeplex.com/">MEF</a>, <a href="http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject.aspx">DynamicObject</a> and
other code to dynamically locator your ViewModels to create a composable application
(Wait, didn’t I just say there were performance issues? Yes, but sometimes you have
to take the hit).
</p>
        <p>
Please post your thoughts on all this, I would be really interested in hearing other
perspectives!
</p>
        <img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=6c743ae9-01c8-4c1b-a9c1-d6ce89f3294a" />
      </body>
      <title>Strategies for a ViewModelLocator in MvvmLight Pt. 1</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,6c743ae9-01c8-4c1b-a9c1-d6ce89f3294a.aspx</guid>
      <link>http://www.milkcarton.com/blog/2011/07/25/Strategies+For+A+ViewModelLocator+In+MvvmLight+Pt+1.aspx</link>
      <pubDate>Mon, 25 Jul 2011 02:59:41 GMT</pubDate>
      <description>&lt;p&gt;
I’ve been using the &lt;a href="http://www.galasoft.ch/mvvm/"&gt;MvvmLight Toolkit&lt;/a&gt; on
a project now for several weeks. At first, the ViewModelLocator pattern the toolkit
uses didn’t bother me. But after you wonder why your view can’t be located and then
debug everything only to discover that you forgot to create the ViewModel in the ViewModelLocator.
&lt;/p&gt;
&lt;p&gt;
I first thought about switching the ViewModelLocator to inherit from &lt;a href="http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject.aspx"&gt;DynamicObject&lt;/a&gt; and
using &lt;a href="http://mef.codeplex.com/"&gt;MEF&lt;/a&gt; to discover the VIewModel’s. A quick
search lead me to discover that &lt;a href="http://johnpapa.net/simple-viewmodel-locator-for-mvvm-the-patients-have-left-the-asylum"&gt;I’m
not&lt;/a&gt; &lt;a href="http://rickrat.wordpress.com/2011/01/24/using-mef-to-link-view-model-locator-and-load-assembly-uis-dynamically/"&gt;the
only&lt;/a&gt; &lt;a href="http://kellabyte.com/2010/08/25/use-mef-to-decouple-discovery-of-your-viewmodels-in-mvvmlights-viewmodellocator/"&gt;one&lt;/a&gt; to
have that same thought &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.milkcarton.com/blog/content/binary/Windows-Live-Writer/7f91385d833f_FD78/wlEmoticon-smile_2.png" /&gt;
&lt;/p&gt;
&lt;p&gt;
The one thing I didn’t like about using Dynamic and MEF for discovering the ViewModel
was the design time experience took a big hit. Locating the ViewModel was now much
more expensive at design time.
&lt;/p&gt;
&lt;p&gt;
I started started doing more thinking, and wondered if I could use &lt;a href="http://msdn.microsoft.com/en-us/library/bb126445.aspx"&gt;T4&lt;/a&gt; to
generate the ViewModelLocator for me. After more thought, I knew I had to be able
to use T4 to generate the ViewModelLocator, heck T4MVC uses it to generate a bunch
of helper classes.
&lt;/p&gt;
&lt;p&gt;
Because I’m big on using IoC in my apps, I’ve also added the ability to get the ViewModel
from an IoC container if the application isn’t in design mode.
&lt;/p&gt;
&lt;p&gt;
There are two files that are required to make this approach work. ViewModelLocator.tt,
and ViewModelLocator.settings.t4. The settings file exists so you can configure the
what’s and how’s. If you use the default setup for MvvmLight, the only thing you will
have to change is the IoC stuff.
&lt;/p&gt;
&lt;p&gt;
To use the T4 ViewModelLocator, delete your existing ViewModelLocator.cs class in
your ViewModel folder, and drop the two T4 files into your ViewModel folder. Once
that happens, you will see a new icon show up in the solution explorer called “Transform
All Templates.” Click that icon to have your ViewModelLocator automatically generated
for you, compile and run &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.milkcarton.com/blog/content/binary/Windows-Live-Writer/7f91385d833f_FD78/wlEmoticon-smile_2.png" /&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.milkcarton.com/blog/content/binary/Windows-Live-Writer/7f91385d833f_FD78/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.milkcarton.com/blog/content/binary/Windows-Live-Writer/7f91385d833f_FD78/image_thumb.png" width="244" height="43" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.milkcarton.com/public/ViewModelLocator.zip"&gt;Download the T4
templates!&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Next time, I’ll write a post about using &lt;a href="http://mef.codeplex.com/"&gt;MEF&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject.aspx"&gt;DynamicObject&lt;/a&gt; and
other code to dynamically locator your ViewModels to create a composable application
(Wait, didn’t I just say there were performance issues? Yes, but sometimes you have
to take the hit).
&lt;/p&gt;
&lt;p&gt;
Please post your thoughts on all this, I would be really interested in hearing other
perspectives!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=6c743ae9-01c8-4c1b-a9c1-d6ce89f3294a" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,6c743ae9-01c8-4c1b-a9c1-d6ce89f3294a.aspx</comments>
      <category>.NET</category>
      <category>MVVM</category>
      <category>MvvmLight</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=268e155c-d507-4dbd-acdc-bcccd84ff701</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,268e155c-d507-4dbd-acdc-bcccd84ff701.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,268e155c-d507-4dbd-acdc-bcccd84ff701.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=268e155c-d507-4dbd-acdc-bcccd84ff701</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I purchased my DS1052E scope several months back. After trying, and failing for days
to get the “Ultrascope” software to work under Windows 7 64 bit, I gave up.
</p>
        <p>
My interest was recently renewed in getting the Ultrascope software to work on my
computer so i decided to give it another go. This time, I succeeded!
</p>
        <p>
To save others the pain I went through, I’ll document the things I did (well, that
i can remember given that I had previous failed attempts). Install the Rigol Ultrascope
software.
</p>
        <p>
Second, download the <a href="http://files.milkcarton.com/public/niusbtmcVista.zip" rel="enclosure">DS1000
Series Windows driver</a> (note, I can’t take credit for these two files, I found
them in another forum). Extract these two files, then go find the device in the Device
Manager. Update the driver and point it to the directory where you extract the driver
files.
</p>
        <p>
Next, download the <a href="http://ftp.ni.com/support/softlib/visa/VISA%20Run-Time%20Engine/5.0.3/visa503runtime.exe">NI-VISA
Run-Time Engine</a> (v5.0.3 as of this writing). Beware, this file weighs in at 71
MB. Install the VISA runtime with the default options (you could probably get away
with just installing the USB portion, but I didn’t try it).
</p>
        <p>
When the NI-VISA installer finally finishes, you might be prompted to reboot. I skipped
this step :-). Run the Ultrascope software, and click on Tools –&gt; Connect to Oscilloscope.
I was prompted with a list of devices, with none of it making much sense, except the
first option “USB0…” I choose that option and everything worked!
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.milkcarton.com/blog/content/binary/WindowsLiveWriter/RigolDS1000SeriesandWindows764bit_142DC/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.milkcarton.com/blog/content/binary/WindowsLiveWriter/RigolDS1000SeriesandWindows764bit_142DC/image_thumb_1.png" width="244" height="161" />
          </a>
        </p>
        <img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=268e155c-d507-4dbd-acdc-bcccd84ff701" />
      </body>
      <title>Rigol DS1000 Series and Windows 7, 64 bit</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,268e155c-d507-4dbd-acdc-bcccd84ff701.aspx</guid>
      <link>http://www.milkcarton.com/blog/2011/04/28/Rigol+DS1000+Series+And+Windows+7+64+Bit.aspx</link>
      <pubDate>Thu, 28 Apr 2011 06:54:10 GMT</pubDate>
      <description>&lt;p&gt;
I purchased my DS1052E scope several months back. After trying, and failing for days
to get the “Ultrascope” software to work under Windows 7 64 bit, I gave up.
&lt;/p&gt;
&lt;p&gt;
My interest was recently renewed in getting the Ultrascope software to work on my
computer so i decided to give it another go. This time, I succeeded!
&lt;/p&gt;
&lt;p&gt;
To save others the pain I went through, I’ll document the things I did (well, that
i can remember given that I had previous failed attempts). Install the Rigol Ultrascope
software.
&lt;/p&gt;
&lt;p&gt;
Second, download the &lt;a href="http://files.milkcarton.com/public/niusbtmcVista.zip" rel="enclosure"&gt;DS1000
Series Windows driver&lt;/a&gt; (note, I can’t take credit for these two files, I found
them in another forum). Extract these two files, then go find the device in the Device
Manager. Update the driver and point it to the directory where you extract the driver
files.
&lt;/p&gt;
&lt;p&gt;
Next, download the &lt;a href="http://ftp.ni.com/support/softlib/visa/VISA%20Run-Time%20Engine/5.0.3/visa503runtime.exe"&gt;NI-VISA
Run-Time Engine&lt;/a&gt; (v5.0.3 as of this writing). Beware, this file weighs in at 71
MB. Install the VISA runtime with the default options (you could probably get away
with just installing the USB portion, but I didn’t try it).
&lt;/p&gt;
&lt;p&gt;
When the NI-VISA installer finally finishes, you might be prompted to reboot. I skipped
this step :-). Run the Ultrascope software, and click on Tools –&amp;gt; Connect to Oscilloscope.
I was prompted with a list of devices, with none of it making much sense, except the
first option “USB0…” I choose that option and everything worked!
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.milkcarton.com/blog/content/binary/WindowsLiveWriter/RigolDS1000SeriesandWindows764bit_142DC/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.milkcarton.com/blog/content/binary/WindowsLiveWriter/RigolDS1000SeriesandWindows764bit_142DC/image_thumb_1.png" width="244" height="161" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=268e155c-d507-4dbd-acdc-bcccd84ff701" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,268e155c-d507-4dbd-acdc-bcccd84ff701.aspx</comments>
      <category>Electronics</category>
      <category>Hobbies</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=756636b5-a7d1-4bb1-b0a8-4faf20f0aab8</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,756636b5-a7d1-4bb1-b0a8-4faf20f0aab8.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,756636b5-a7d1-4bb1-b0a8-4faf20f0aab8.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=756636b5-a7d1-4bb1-b0a8-4faf20f0aab8</wfw:commentRss>
      <title>CNC Hardware – Part Deux</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,756636b5-a7d1-4bb1-b0a8-4faf20f0aab8.aspx</guid>
      <link>http://www.milkcarton.com/blog/2011/03/22/CNC+Hardware+Part+Deux.aspx</link>
      <pubDate>Tue, 22 Mar 2011 06:22:21 GMT</pubDate>
      <description>&lt;p&gt;
After I re-read &lt;a href="/blog/2011/03/21/CNC+Machine+Setup.aspx"&gt;my last post&lt;/a&gt;,
I realized I kind of cheesed out on the drill bit part, so I figured I would more
fully flesh that part out, plus detail the opto-isolated limit switches I purchased.
&lt;/p&gt;
&lt;h2&gt;Drill and Router Bits
&lt;/h2&gt;
&lt;p&gt;
For hole drilling, I looked at buying &lt;a href="http://drillcity.stores.yahoo.net/recudrbitse.html"&gt;a
kit like this one from Drill Bit City&lt;/a&gt;, but ultimately decided that I would just
get a 10 pack of each of a few different sizes. I ended up getting #71, #70, #66 and
#60 drill bits from Drill Bit City.
&lt;/p&gt;
&lt;p&gt;
For milling (cutting out), I got a 10 pack of .0625 down-cut carbide bits, also from
Drill Bit City.
&lt;/p&gt;
&lt;p&gt;
For trace isolation, I picked up a 10 pack of 60 degree carbide “V” bits off of eBay.
&lt;/p&gt;
&lt;h2&gt;Limit Switches
&lt;/h2&gt;
&lt;p&gt;
The purpose of the limit switch is to keep the controller software from driving any
of the axis's to their physical limit and causing damage.
&lt;/p&gt;
&lt;p&gt;
You can certainly run your CNC machine without limit switches, but honestly, if your
going to spend a minimum of $1500 on your setup, why not spend a few more dollars
(and a few input pins on your break out board) and prevent costly damage to your machine?
&lt;/p&gt;
&lt;p&gt;
When I was doing research on limit switches, I was originally considering using a &lt;a href="http://en.wikipedia.org/wiki/Miniature_snap-action_switch"&gt;standard
lever actuated micro-switch&lt;/a&gt;. But I had some questions and concerns regarding their
accuracy. Over time, as a axis slams into the switch, it will deform the lever.
&lt;/p&gt;
&lt;p&gt;
When a microswitch is used on say an arcade button, any imperfection or deformation
of the lever will go unnoticed by the user. But in the world of CNC, accuracy and
repeatability are everything.
&lt;/p&gt;
&lt;p&gt;
After doing a lot of research, I stumbled upon &lt;a href="http://colinmackenzie.net/index.php?option=com_content&amp;view=article&amp;id=36:cnc-or-reprap-opto-limit-a-home-switches&amp;catid=1:cnc-general&amp;Itemid=20"&gt;Colin
Mackenzie’s Opto-Isolated Limit Switches&lt;/a&gt;. Colin had the same concerns I had regarding
using physical limit switches and came up with an opto-isolated switch which can be
wired in an “OR” configuration.
&lt;/p&gt;
&lt;p&gt;
While the opto-isolated limit switches are a little bit more expensive than a typical
micro-switch (at around $2 - $2.50), at $8.50, I didn’t find the cost difference to
be to great.
&lt;/p&gt;
&lt;p&gt;
Next time, I’ll go into the software setup.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=756636b5-a7d1-4bb1-b0a8-4faf20f0aab8" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,756636b5-a7d1-4bb1-b0a8-4faf20f0aab8.aspx</comments>
      <category>CNC</category>
      <category>Hobbies</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=8a720a42-686d-4551-8e0a-94b5753a5671</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,8a720a42-686d-4551-8e0a-94b5753a5671.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,8a720a42-686d-4551-8e0a-94b5753a5671.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=8a720a42-686d-4551-8e0a-94b5753a5671</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
For almost 10 years I’ve wanted a <a href="http://en.wikipedia.org/wiki/Numerical_control">CNC
machine</a>. I found plans on the internet years ago, but didn’t have any money, or
the right set of tools at the time to act upon that goal.
</p>
        <p>
A few weeks back, I was surfing <a href="http://www.instructables.com/">Instructables</a> and
found instructions for a crude looking CNC based on a moving table design. That rekindled
my desire to own a CNC machine.
</p>
        <p>
After a lot of searching, and reading, I came across the <a href="http://www.probotix.com/FireBall_v90_cnc_router_kit/">FireBall
V90 Kit</a> from Probotix. They suckered me in with the $599 base price. In all my
research, unless you were doing a crude design, you were going to spend at least 500-600
on parts and materials to build the base system so I figured this was a good price.
</p>
        <h2>Hardware
</h2>
        <p>
I ordered my kit with pretty much everything as proposed by Probotix:
</p>
        <ul>
          <li>
The “best” motor/driver kit</li>
          <li>
            <a href="http://www.cncroutersource.com/precision-acme-leadscrew-nut.html">Anti-backlash</a> X
and Y nuts</li>
          <li>
RF isolated breakout board</li>
          <li>
Large enclosure</li>
          <li>
40V DC linear power supply</li>
          <li>
MDF spoil board</li>
          <li>
MeshCam Bundle</li>
        </ul>
        <p>
I wanted to go with the aluminum T-Slot for the spoil board, but figured I could do
that upgrade later given that its a $200 upgrade. Turns out, its a good thing I waited,
I found some <a href="http://www.amazon.com/80-20-2012-T-SLOTTED-EXTRUSION/dp/B001F0I3LM/ref=pd_sbs_indust_2">80/20
T-Slot on Amazon</a> for $13.44 / 48” (~1.22 meters) section.
</p>
        <p>
I will have to cut that into 18” (45.72 cm) sections and either weld them together,
or bolt them to a piece of MDF making sure that the top surface is flat. Thankfully,
a good friend of mine has all the tools to weld aluminum.
</p>
        <h2>Router Unit
</h2>
        <p>
For the spindle (the cutting head) I went with a Wolfgang Engineering TB650. The TB650
is an upgrade over the TB350 which gets very high marks.
</p>
        <p>
For cutting bits, I ordered a variety of bits from <a href="http://drillcity.stores.yahoo.net/">Drill
Bit City</a> for both hole drilling, and I went with carbide #71 down-cut carbide
bits to do the actual milling of the board (cutting out from the stock).
</p>
        <p>
I also ordered some 60 degree “V” bits from Carbide World so I can do PCB trace isolation.
</p>
        <p>
Next time, I’ll detail my software setup.
</p>
        <img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=8a720a42-686d-4551-8e0a-94b5753a5671" />
      </body>
      <title>CNC Machine Setup</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,8a720a42-686d-4551-8e0a-94b5753a5671.aspx</guid>
      <link>http://www.milkcarton.com/blog/2011/03/21/CNC+Machine+Setup.aspx</link>
      <pubDate>Mon, 21 Mar 2011 13:13:03 GMT</pubDate>
      <description>&lt;p&gt;
For almost 10 years I’ve wanted a &lt;a href="http://en.wikipedia.org/wiki/Numerical_control"&gt;CNC
machine&lt;/a&gt;. I found plans on the internet years ago, but didn’t have any money, or
the right set of tools at the time to act upon that goal.
&lt;/p&gt;
&lt;p&gt;
A few weeks back, I was surfing &lt;a href="http://www.instructables.com/"&gt;Instructables&lt;/a&gt; and
found instructions for a crude looking CNC based on a moving table design. That rekindled
my desire to own a CNC machine.
&lt;/p&gt;
&lt;p&gt;
After a lot of searching, and reading, I came across the &lt;a href="http://www.probotix.com/FireBall_v90_cnc_router_kit/"&gt;FireBall
V90 Kit&lt;/a&gt; from Probotix. They suckered me in with the $599 base price. In all my
research, unless you were doing a crude design, you were going to spend at least 500-600
on parts and materials to build the base system so I figured this was a good price.
&lt;/p&gt;
&lt;h2&gt;Hardware
&lt;/h2&gt;
&lt;p&gt;
I ordered my kit with pretty much everything as proposed by Probotix:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
The “best” motor/driver kit&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.cncroutersource.com/precision-acme-leadscrew-nut.html"&gt;Anti-backlash&lt;/a&gt; X
and Y nuts&lt;/li&gt;
&lt;li&gt;
RF isolated breakout board&lt;/li&gt;
&lt;li&gt;
Large enclosure&lt;/li&gt;
&lt;li&gt;
40V DC linear power supply&lt;/li&gt;
&lt;li&gt;
MDF spoil board&lt;/li&gt;
&lt;li&gt;
MeshCam Bundle&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I wanted to go with the aluminum T-Slot for the spoil board, but figured I could do
that upgrade later given that its a $200 upgrade. Turns out, its a good thing I waited,
I found some &lt;a href="http://www.amazon.com/80-20-2012-T-SLOTTED-EXTRUSION/dp/B001F0I3LM/ref=pd_sbs_indust_2"&gt;80/20
T-Slot on Amazon&lt;/a&gt; for $13.44 / 48” (~1.22 meters) section.
&lt;/p&gt;
&lt;p&gt;
I will have to cut that into 18” (45.72 cm) sections and either weld them together,
or bolt them to a piece of MDF making sure that the top surface is flat. Thankfully,
a good friend of mine has all the tools to weld aluminum.
&lt;/p&gt;
&lt;h2&gt;Router Unit
&lt;/h2&gt;
&lt;p&gt;
For the spindle (the cutting head) I went with a Wolfgang Engineering TB650. The TB650
is an upgrade over the TB350 which gets very high marks.
&lt;/p&gt;
&lt;p&gt;
For cutting bits, I ordered a variety of bits from &lt;a href="http://drillcity.stores.yahoo.net/"&gt;Drill
Bit City&lt;/a&gt; for both hole drilling, and I went with carbide #71 down-cut carbide
bits to do the actual milling of the board (cutting out from the stock).
&lt;/p&gt;
&lt;p&gt;
I also ordered some 60 degree “V” bits from Carbide World so I can do PCB trace isolation.
&lt;/p&gt;
&lt;p&gt;
Next time, I’ll detail my software setup.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=8a720a42-686d-4551-8e0a-94b5753a5671" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,8a720a42-686d-4551-8e0a-94b5753a5671.aspx</comments>
      <category>CNC</category>
      <category>Hobbies</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=32f38277-0acf-4a32-89b9-c2154ef136b7</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,32f38277-0acf-4a32-89b9-c2154ef136b7.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,32f38277-0acf-4a32-89b9-c2154ef136b7.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=32f38277-0acf-4a32-89b9-c2154ef136b7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At the Fall 2010 DevConnections keynote, Scott Guthrie demo’d <a href="http://nuget.codeplex.com/">NuGet</a> (formally
Nupack). After seeing how easy NuGet makes it to install project references and resolve
dependencies, I had to try it!
</p>
        <p>
After installing CTP1 of NuGet and installing a bunch of packages, I found out I needed
the latest version (the 10-26-2010 build) in order to install some of the packages
I wanted. Well, between CTP1 and the 10-26-2010 build, the NuSpec file format has
changed slightly, making packages created with CTP1 and the 10-26-2010 build incompatible.
</p>
        <p>
I decided to pop open a .nupkg (.nupkg the file extension of a NuGet package) package
file using <a href="http://www.7-zip.org/">7-Zip</a> (a .nupkg file is really just
a .zip file). Inside I saw a .nuspec file.
</p>
        <p>
Opening up the .nuspec file reveals its an xml file. After comparing a CTP1 and a
10-26-2010 build version of a .nuspec file I discovered the only difference is an
xml namespace reference.
</p>
        <p>
CTP 1 version of a .nuspec file: 
</p>
        <pre>&lt;package&gt;
    &lt;metadata&gt;
        ...</pre>
        <p>
        </p>
        <p>
10-26-2010 build version of a .nuspec file:
</p>
        <pre>&lt;package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  &lt;metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"&gt;</pre>
        <p>
It took a few minutes to update all my .nupkg files to the new format and now everything
works again!
</p>
        <img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=32f38277-0acf-4a32-89b9-c2154ef136b7" />
      </body>
      <title>Upgrading your installed NuGet packages to CTP2</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,32f38277-0acf-4a32-89b9-c2154ef136b7.aspx</guid>
      <link>http://www.milkcarton.com/blog/2010/11/07/Upgrading+Your+Installed+NuGet+Packages+To+CTP2.aspx</link>
      <pubDate>Sun, 07 Nov 2010 20:08:09 GMT</pubDate>
      <description>&lt;p&gt;
At the Fall 2010 DevConnections keynote, Scott Guthrie demo’d &lt;a href="http://nuget.codeplex.com/"&gt;NuGet&lt;/a&gt; (formally
Nupack). After seeing how easy NuGet makes it to install project references and resolve
dependencies, I had to try it!
&lt;/p&gt;
&lt;p&gt;
After installing CTP1 of NuGet and installing a bunch of packages, I found out I needed
the latest version (the 10-26-2010 build) in order to install some of the packages
I wanted. Well, between CTP1 and the 10-26-2010 build, the NuSpec file format has
changed slightly, making packages created with CTP1 and the 10-26-2010 build incompatible.
&lt;/p&gt;
&lt;p&gt;
I decided to pop open a .nupkg (.nupkg the file extension of a NuGet package) package
file using &lt;a href="http://www.7-zip.org/"&gt;7-Zip&lt;/a&gt; (a .nupkg file is really just
a .zip file). Inside I saw a .nuspec file.
&lt;/p&gt;
&lt;p&gt;
Opening up the .nuspec file reveals its an xml file. After comparing a CTP1 and a
10-26-2010 build version of a .nuspec file I discovered the only difference is an
xml namespace reference.
&lt;/p&gt;
&lt;p&gt;
CTP 1 version of a .nuspec file: 
&lt;/p&gt;
&lt;pre&gt;&amp;lt;package&amp;gt;
    &amp;lt;metadata&amp;gt;
        ...&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
10-26-2010 build version of a .nuspec file:
&lt;/p&gt;
&lt;pre&gt;&amp;lt;package xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;
  &amp;lt;metadata xmlns=&amp;quot;http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd&amp;quot;&amp;gt;&lt;/pre&gt;
&lt;p&gt;
It took a few minutes to update all my .nupkg files to the new format and now everything
works again!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=32f38277-0acf-4a32-89b9-c2154ef136b7" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,32f38277-0acf-4a32-89b9-c2154ef136b7.aspx</comments>
      <category>.NET</category>
      <category>HowTo</category>
      <category>NuGet</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=50ca5ba0-f5bf-48d8-a3ad-501b0521db2f</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,50ca5ba0-f5bf-48d8-a3ad-501b0521db2f.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,50ca5ba0-f5bf-48d8-a3ad-501b0521db2f.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=50ca5ba0-f5bf-48d8-a3ad-501b0521db2f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Tonight, I did a presentation on "Developing a .NET application onMac OS X using MonoMac"
at the <a href="http://akdotnet.ning.com/">Alaska .NET Users Group</a> meeting. I
hope everyone enjoyed my presentation and learned something from it! I'd appreciate
any feedback anyone has to offer!
</p>
        <p>
        </p>
        <p>
The download link is at the end of this blog post. If you download the source, you
will probably want to review all the <a href="http://www.milkcarton.com/blog/CategoryView,category,MonoMac.aspx">posts
I've written on MonoMac</a> as well.
</p>
        <p>
          <img src="http://www.milkcarton.com/blog/content/binary/MovieTimes_screenshot.png" />
        </p>
        <h3>Source Code
</h3>
        <p>
          <a href="http://www.milkcarton.com/blog/content/binary/MovieTimes2.zip">
            <img src="http://www.milkcarton.com/blog/content/binary/Zip.png" />
            <br />
MovieTimes source code</a>
        </p>
        <img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=50ca5ba0-f5bf-48d8-a3ad-501b0521db2f" />
      </body>
      <title>Source code for the MonoMac presentation</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,50ca5ba0-f5bf-48d8-a3ad-501b0521db2f.aspx</guid>
      <link>http://www.milkcarton.com/blog/2010/07/28/Source+Code+For+The+MonoMac+Presentation.aspx</link>
      <pubDate>Wed, 28 Jul 2010 06:53:29 GMT</pubDate>
      <description>&lt;p&gt;
Tonight, I did a presentation on "Developing a .NET application onMac OS X using MonoMac"
at the &lt;a href="http://akdotnet.ning.com/"&gt;Alaska .NET Users Group&lt;/a&gt; meeting. I
hope everyone enjoyed my presentation and learned something from it! I'd appreciate
any feedback anyone has to offer!&lt;p&gt;
&lt;p&gt;
The download link is at the end of this blog post. If you download the source, you
will probably want to review all the &lt;a href="http://www.milkcarton.com/blog/CategoryView,category,MonoMac.aspx"&gt;posts
I've written on MonoMac&lt;/a&gt; as well.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.milkcarton.com/blog/content/binary/MovieTimes_screenshot.png" /&gt;
&lt;/p&gt;
&lt;h3&gt;Source Code
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://www.milkcarton.com/blog/content/binary/MovieTimes2.zip"&gt;&lt;img src="http://www.milkcarton.com/blog/content/binary/Zip.png"&gt;
&lt;br /&gt;
MovieTimes source code&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=50ca5ba0-f5bf-48d8-a3ad-501b0521db2f" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,50ca5ba0-f5bf-48d8-a3ad-501b0521db2f.aspx</comments>
      <category>Mac OS X</category>
      <category>Mono</category>
      <category>MonoMac</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=a2958363-9978-4231-8889-11f1d92dd33c</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,a2958363-9978-4231-8889-11f1d92dd33c.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,a2958363-9978-4231-8889-11f1d92dd33c.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a2958363-9978-4231-8889-11f1d92dd33c</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I use and enjoy my Microsoft 4000 keyboard very much. Its the best keyboard I found
since the original Microsoft Natural Keyboard. Key placement makes sense, is comfortable
to type on, I love the media keys (but honestly, why no love for next and previous
track?).
</p>
        <p>
The one thing I don't like however, is how Mac OSX handles PC keyboards. Why does
home/end move me to the beginning and end of my document? Everybody knows they are
supposed to move the cursor to the beginning and end of the current line. Thankfully,
we have <a href="http://doublecommand.sourceforge.net/">Double Command</a> to help
fix the issues! If only it could make the page up/down keys function like on the PC...
</p>
        <img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=a2958363-9978-4231-8889-11f1d92dd33c" />
      </body>
      <title>Make a PC keyboard on a Mac function like it should</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,a2958363-9978-4231-8889-11f1d92dd33c.aspx</guid>
      <link>http://www.milkcarton.com/blog/2010/07/09/Make+A+PC+Keyboard+On+A+Mac+Function+Like+It+Should.aspx</link>
      <pubDate>Fri, 09 Jul 2010 02:54:57 GMT</pubDate>
      <description>&lt;p&gt;
I use and enjoy my Microsoft 4000 keyboard very much. Its the best keyboard I found
since the original Microsoft Natural Keyboard. Key placement makes sense, is comfortable
to type on, I love the media keys (but honestly, why no love for next and previous
track?).
&lt;/p&gt;
&lt;p&gt;
The one thing I don't like however, is how Mac OSX handles PC keyboards. Why does
home/end move me to the beginning and end of my document? Everybody knows they are
supposed to move the cursor to the beginning and end of the current line. Thankfully,
we have &lt;a href="http://doublecommand.sourceforge.net/"&gt;Double Command&lt;/a&gt; to help
fix the issues! If only it could make the page up/down keys function like on the PC...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=a2958363-9978-4231-8889-11f1d92dd33c" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,a2958363-9978-4231-8889-11f1d92dd33c.aspx</comments>
      <category>Mac OS X</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=4cab2fa5-e0f3-476a-8668-3f3f857c01ea</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,4cab2fa5-e0f3-476a-8668-3f3f857c01ea.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,4cab2fa5-e0f3-476a-8668-3f3f857c01ea.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4cab2fa5-e0f3-476a-8668-3f3f857c01ea</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
After I finished creating a sample application to test out the capabilities of Mono
on the Mac, I figured I should create the same application in Objective-C to have
an accurate understanding of what the pain points are in each technology.
</p>
        <p>
The first big pain point I've come across is creating the bindings to call a web service
in Objective-C. Apple provides a utility called WSMakeStubs. The utility makes creating
the stubs easy and painless, or so it would seem. Out of the box the code doesn't
compile.
</p>
        <p>
For reasons unknown to me, WSMakeStubs utility makes duplicate method names. The issues
people have with WSMakeStubs are so bad, almost every article I've read, everyone
advocates using NSUrlConnection and NSXMLParser and rolling your own service calls.
</p>
        <p>
Its 2010 Apple, how about coming up with a viable solution to making web service calls?
Even PHP has a good web services proxy generator.
</p>
        <img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=4cab2fa5-e0f3-476a-8668-3f3f857c01ea" />
      </body>
      <title>Whats up with the state of web services in objective-c?</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,4cab2fa5-e0f3-476a-8668-3f3f857c01ea.aspx</guid>
      <link>http://www.milkcarton.com/blog/2010/07/07/Whats+Up+With+The+State+Of+Web+Services+In+Objectivec.aspx</link>
      <pubDate>Wed, 07 Jul 2010 07:15:56 GMT</pubDate>
      <description>&lt;p&gt;
After I finished creating a sample application to test out the capabilities of Mono
on the Mac, I figured I should create the same application in Objective-C to have
an accurate understanding of what the pain points are in each technology.
&lt;/p&gt;
&lt;p&gt;
The first big pain point I've come across is creating the bindings to call a web service
in Objective-C. Apple provides a utility called WSMakeStubs. The utility makes creating
the stubs easy and painless, or so it would seem. Out of the box the code doesn't
compile.
&lt;/p&gt;
&lt;p&gt;
For reasons unknown to me, WSMakeStubs utility makes duplicate method names. The issues
people have with WSMakeStubs are so bad, almost every article I've read, everyone
advocates using NSUrlConnection and NSXMLParser and rolling your own service calls.
&lt;/p&gt;
&lt;p&gt;
Its 2010 Apple, how about coming up with a viable solution to making web service calls?
Even PHP has a good web services proxy generator.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=4cab2fa5-e0f3-476a-8668-3f3f857c01ea" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,4cab2fa5-e0f3-476a-8668-3f3f857c01ea.aspx</comments>
      <category>Mac OS X</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=334639e4-7e22-4df6-8239-e7d5a4433b65</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,334639e4-7e22-4df6-8239-e7d5a4433b65.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,334639e4-7e22-4df6-8239-e7d5a4433b65.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=334639e4-7e22-4df6-8239-e7d5a4433b65</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <title>Databinding to an NSTableView with a MonoMac app</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,334639e4-7e22-4df6-8239-e7d5a4433b65.aspx</guid>
      <link>http://www.milkcarton.com/blog/2010/07/05/Databinding+To+An+NSTableView+With+A+MonoMac+App.aspx</link>
      <pubDate>Mon, 05 Jul 2010 16:00:00 GMT</pubDate>
      <description>&lt;p&gt;
I’m working on my presentation for the &lt;a href="http://akdotnet.ning.com/"&gt;Alaska
.NET Users Group&lt;/a&gt;. My goal is to build an app that consumes a web service, and
displays the data. After getting the web service piece going, the next step was to
display that data in a NSTableView.
&lt;/p&gt;
&lt;p&gt;
I battled for hours and hours trying to figure out how to create a NSTableViewDataSource,
and it turns out I was making things way to complicated. I did some searching on the
web, but couldn’t really find anything except a &lt;a href="http://lists.ximian.com/pipermail/mono-osx/2010-June/002965.html"&gt;post&lt;/a&gt; by &lt;a href="http://twitter.com/moshakis"&gt;John
Moshakis&lt;/a&gt; on the Mono-osx mailing list which gave me some hope that someone had
figured it out.
&lt;/p&gt;
&lt;p&gt;
I emailed John, and he was gracious enough to send me some source code to work from.
It turns out, I what I had wasn’t far off the mark, I just needed a few pointers.
&lt;/p&gt;
&lt;h3&gt;The DataSource Code
&lt;/h3&gt;
&lt;div style="font-family: consolas,; font-size: small" class="csharp" #ffffff;?="#ffffff;?" background-color:="background-color:" monospace;="monospace;" courier,="courier," New?,="New?," Courier="Courier"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;using&lt;/span&gt; &lt;span style="color: #008080"&gt;System&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;using&lt;/span&gt; &lt;span style="color: #008080"&gt;System.Collections&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;using&lt;/span&gt; &lt;span style="color: #008080"&gt;MonoMac.Foundation&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;using&lt;/span&gt; &lt;span style="color: #008080"&gt;MonoMac.AppKit&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;using&lt;/span&gt; &lt;span style="color: #008080"&gt;MovieTimes.BusinessLogic&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;using&lt;/span&gt; &lt;span style="color: #008080"&gt;System.Collections.Generic&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;[&lt;/span&gt;Register&lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #666666"&gt;&amp;quot;MyItemDataSource&amp;quot;&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;]&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; &lt;span style="color: #6666cc; font-weight: bold"&gt;class&lt;/span&gt; MyItemDataSource &lt;span style="color: #008000"&gt;:&lt;/span&gt; NSTableViewDataSource
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; List&lt;span style="color: #008000"&gt;&amp;lt;&lt;/span&gt;MyItem&lt;span style="color: #008000"&gt;&amp;gt;&lt;/span&gt; MyItems &lt;span style="color: #008000"&gt;{&lt;/span&gt; get&lt;span style="color: #008000"&gt;;&lt;/span&gt; set&lt;span style="color: #008000"&gt;;&lt;/span&gt; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;static&lt;/span&gt; MyItemDataSource &lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;[&lt;/span&gt;Export&lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #666666"&gt;&amp;quot;numberOfRowsInTableView:&amp;quot;&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;]&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; &lt;span style="color: #6666cc; font-weight: bold"&gt;int&lt;/span&gt; numberOfRowsInTableView &lt;span style="color: #008000"&gt;(&lt;/span&gt;NSTableView
aTableView&lt;span style="color: #008000"&gt;)&lt;/span&gt; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;if&lt;/span&gt; &lt;span style="color: #008000"&gt;(&lt;/span&gt;MyItems &lt;span style="color: #008000"&gt;==&lt;/span&gt; &lt;span style="color: #0600ff; font-weight: bold"&gt;null&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;return&lt;/span&gt; &lt;span style="color: #ff0000"&gt;0&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;return&lt;/span&gt; MyItems&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;Count&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;[&lt;/span&gt;Export&lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #666666"&gt;&amp;quot;tableView:objectValueForTableColumn:row:&amp;quot;&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;]&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; NSObject
objectValueForTableColumn &lt;span style="color: #008000"&gt;(&lt;/span&gt;NSTableView aTableView,
NSTableColumn aTableColumn, &lt;span style="color: #6666cc; font-weight: bold"&gt;int&lt;/span&gt; rowIndex&lt;span style="color: #008000"&gt;)&lt;/span&gt; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;return&lt;/span&gt; &lt;a href="http://www.google.com/search?q=new+msdn.microsoft.com"&gt;&lt;span style="color: #008000"&gt;new&lt;/span&gt;&lt;/a&gt; NSString&lt;span style="color: #008000"&gt;(&lt;/span&gt;MyItems&lt;span style="color: #008000"&gt;[&lt;/span&gt;rowIndex&lt;span style="color: #008000"&gt;]&lt;/span&gt;&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;Name&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; &lt;span style="color: #6666cc; font-weight: bold"&gt;void&lt;/span&gt; Items&lt;span style="color: #008000"&gt;(&lt;/span&gt;List&lt;span style="color: #008000"&gt;&amp;lt;&lt;/span&gt;MyItem&lt;span style="color: #008000"&gt;&amp;gt;&lt;/span&gt; items&lt;span style="color: #008000"&gt;)&lt;/span&gt; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
MyItems &lt;span style="color: #008000"&gt;=&lt;/span&gt; items&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; &lt;span style="color: #6666cc; font-weight: bold"&gt;class&lt;/span&gt; MyItemDataSourceDelegate &lt;span style="color: #008000"&gt;:&lt;/span&gt; NSTableViewDelegate &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; &lt;span style="color: #0600ff; font-weight: bold"&gt;event&lt;/span&gt; EventHandler&lt;span style="color: #008000"&gt;&amp;lt;&lt;/span&gt;MyItemChangedEventArgs&lt;span style="color: #008000"&gt;&amp;gt;&lt;/span&gt; MyItemChanged&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; MyItemDataSourceDelegate &lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;:&lt;/span&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;base&lt;/span&gt;&lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&amp;#160; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; &lt;span style="color: #0600ff; font-weight: bold"&gt;override&lt;/span&gt; &lt;span style="color: #6666cc; font-weight: bold"&gt;void&lt;/span&gt; SelectionDidChange&lt;span style="color: #008000"&gt;(&lt;/span&gt;NSNotification
notification&lt;span style="color: #008000"&gt;)&lt;/span&gt; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
var table &lt;span style="color: #008000"&gt;=&lt;/span&gt; notification&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #6666cc; font-weight: bold"&gt;Object&lt;/span&gt; &lt;span style="color: #0600ff; font-weight: bold"&gt;as&lt;/span&gt; NSTableView&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
var ds &lt;span style="color: #008000"&gt;=&lt;/span&gt; table&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;DataSource&lt;/span&gt; &lt;span style="color: #0600ff; font-weight: bold"&gt;as&lt;/span&gt; MyItemDataSource&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
var rowNum &lt;span style="color: #008000"&gt;=&lt;/span&gt; table&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;SelectedRow&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;if&lt;/span&gt; &lt;span style="color: #008000"&gt;(&lt;/span&gt;rowNum &lt;span style="color: #008000"&gt;&amp;gt;=&lt;/span&gt; &lt;span style="color: #ff0000"&gt;0&lt;/span&gt; &lt;span style="color: #008000"&gt;&amp;amp;&amp;amp;&lt;/span&gt; rowNum &lt;span style="color: #008000"&gt;&amp;lt;&lt;/span&gt; ds&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;MyItems&lt;/span&gt;&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;Count&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OnMyItemChanged&lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;a href="http://www.google.com/search?q=new+msdn.microsoft.com"&gt;&lt;span style="color: #008000"&gt;new&lt;/span&gt;&lt;/a&gt; MyItemChangedEventArgs&lt;span style="color: #008000"&gt;(&lt;/span&gt;ds&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;MyItems&lt;/span&gt;&lt;span style="color: #008000"&gt;[&lt;/span&gt;rowNum&lt;span style="color: #008000"&gt;]&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;protected&lt;/span&gt; &lt;span style="color: #6666cc; font-weight: bold"&gt;void&lt;/span&gt; OnMyItemChanged&lt;span style="color: #008000"&gt;(&lt;/span&gt;MyItemChangedEventArgs
e&lt;span style="color: #008000"&gt;)&lt;/span&gt; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;if&lt;/span&gt; &lt;span style="color: #008000"&gt;(&lt;/span&gt;MyItemChanged &lt;span style="color: #008000"&gt;!=&lt;/span&gt; &lt;span style="color: #0600ff; font-weight: bold"&gt;null&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
MyItemChanged&lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;this&lt;/span&gt;,
e&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; 
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; &lt;span style="color: #6666cc; font-weight: bold"&gt;class&lt;/span&gt; MyItemChangedEventArgs &lt;span style="color: #008000"&gt;:&lt;/span&gt; EventArgs &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; MyItem
MyItem &lt;span style="color: #008000"&gt;{&lt;/span&gt; get&lt;span style="color: #008000"&gt;;&lt;/span&gt; set&lt;span style="color: #008000"&gt;;&lt;/span&gt; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; MyItemChangedEventArgs&lt;span style="color: #008000"&gt;(&lt;/span&gt;MyItem
i&lt;span style="color: #008000"&gt;)&lt;/span&gt; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
MyItem &lt;span style="color: #008000"&gt;=&lt;/span&gt; i&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The code is kind of long, and I’ve removed all the normal guard code you would use
for the sake of brevity. But lets dissect the code. The first part, lines 8 – 31 is
the actual data source. It simply listens for a few messages (numberOfRowsInTableView
and objectValueForTableColumn) and allows items to be added to the data source (line
28). The next part, lines 33 – 54 fire off an event when the selected item has changed
in the NSTableView instance.
&lt;/p&gt;
&lt;h3&gt;The Window Code
&lt;/h3&gt;
&lt;div style="font-family: consolas,; font-size: small" class="csharp" #ffffff;?="#ffffff;?" background-color:="background-color:" monospace;="monospace;" courier,="courier," New?,="New?," Courier="Courier"&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #0600ff; font-weight: bold"&gt;public&lt;/span&gt; &lt;span style="color: #0600ff; font-weight: bold"&gt;override&lt;/span&gt; &lt;span style="color: #6666cc; font-weight: bold"&gt;void&lt;/span&gt; WindowDidLoad &lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt; &lt;span style="color: #008000"&gt;{&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;base&lt;/span&gt;&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;WindowDidLoad&lt;/span&gt; &lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;
var myDel &lt;span style="color: #008000"&gt;=&lt;/span&gt; &lt;a href="http://www.google.com/search?q=new+msdn.microsoft.com"&gt;&lt;span style="color: #008000"&gt;new&lt;/span&gt;&lt;/a&gt; MyItemDataSourceDelegate&lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;
myDel&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;ItemChanged&lt;/span&gt; &lt;span style="color: #008000"&gt;+=&lt;/span&gt; ItemChanged&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;this&lt;/span&gt;&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;someTable&lt;/span&gt;&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #6666cc; font-weight: bold"&gt;Delegate&lt;/span&gt; &lt;span style="color: #008000"&gt;=&lt;/span&gt; myDel&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style="background-color: #f4f4f4"&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0600ff; font-weight: bold"&gt;this&lt;/span&gt;&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;someTable&lt;/span&gt;&lt;span style="color: #008000"&gt;.&lt;/span&gt;&lt;span style="color: #0000ff"&gt;DataSource&lt;/span&gt; &lt;span style="color: #008000"&gt;=&lt;/span&gt; &lt;a href="http://www.google.com/search?q=new+msdn.microsoft.com"&gt;&lt;span style="color: #008000"&gt;new&lt;/span&gt;&lt;/a&gt; MyItemDataSource&lt;span style="color: #008000"&gt;(&lt;/span&gt;&lt;span style="color: #008000"&gt;)&lt;/span&gt;&lt;span style="color: #008000"&gt;;&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;p&gt;
In the window controller, paste the above code to have code run when you window loads.
For WinForms people, public override void WindowDidLoad is the equivilent of protected
override void OnLoad().
&lt;/p&gt;
&lt;p&gt;
So what does the window controller code do? First off, we create our delegate (note,
delegates in Cocoa are &lt;strong&gt;not&lt;/strong&gt; the same thing as in C#), and wire up
to the changed event, then we assign the newly created delegate and a data source
to our table.
&lt;/p&gt;
&lt;p&gt;
Any questions, thoughts or feedback? Hit me up in the comments, or &lt;a href="http://twitter.com/akcoder"&gt;follow
me on twitter&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=334639e4-7e22-4df6-8239-e7d5a4433b65" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,334639e4-7e22-4df6-8239-e7d5a4433b65.aspx</comments>
      <category>C#</category>
      <category>Mac OS X</category>
      <category>Mono</category>
      <category>MonoMac</category>
    </item>
    <item>
      <trackback:ping>http://www.milkcarton.com/blog/Trackback.aspx?guid=e31f3ad6-343d-4a2e-98a4-0e38a159b4c5</trackback:ping>
      <pingback:server>http://www.milkcarton.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.milkcarton.com/blog/PermaLink,guid,e31f3ad6-343d-4a2e-98a4-0e38a159b4c5.aspx</pingback:target>
      <dc:creator>Dan Morphis</dc:creator>
      <wfw:comment>http://www.milkcarton.com/blog/CommentView,guid,e31f3ad6-343d-4a2e-98a4-0e38a159b4c5.aspx</wfw:comment>
      <wfw:commentRss>http://www.milkcarton.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=e31f3ad6-343d-4a2e-98a4-0e38a159b4c5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
For the past week or so, I've been developing a couple of sample apps in <a href="http://www.mono-project.com/">Mono</a> with
Cocoa on my Mac. In that time, I've struggled quite a bit, and learned quite a bit.
One of the biggest things I've learned is things are much harder when you try and
mix-in paradimes for which things were not designed.
</p>
        <p>
Take for example <a href="http://www.cocoadev.com/index.pl?NSTableViewTutorial">NSTableView</a>.
Because <a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a> is <a href="http://en.wikipedia.org/wiki/Duck_typing">duck
typed</a>, you set Delegate property of your table to <em>this</em> (<em>self</em> in
Objective-C) and implement the selectionDidChange method and you will get notified
when a row is selected.
</p>
        <p>
Because C# is not <a href="http://en.wikipedia.org/wiki/Duck_typing">duck typed</a>,
you have to <a href="http://www.milkcarton.com/blog/2010/07/05/Databinding+To+An+NSTableView+With+A+MonoMac+App.aspx">write
a whole lot of ceremony code</a> to get notified when a row is selected. And figuring
out that ceremony was a huge battle. I wouldn't have won the war without the help
of <a href="http://twitter.com/moshakis"> John Moshakis</a>. Another thing thats not
supported is <em>Register</em>ing a generic type, or setting a generic .NET type the
property of a Cocoa widget.
</p>
        <p>
That means the ceremony code has to be duplicated every time, for every different
type of object. I actually tried to make a generic version of my <a href="http://www.milkcarton.com/blog/2010/07/05/Databinding+To+An+NSTableView+With+A+MonoMac+App.aspx">Databinding
to an NSTableView</a> blog post, but I was thwarted by an "Invalid IL exception."
Hopefully this is just a defect, and not a limitation when dealing with Cocoa.
</p>
        <p>
I would file a defect on this issue with the mono project, but Novell requires you
to create an account to add a defect to their bug tracker. I can understand why they
want you to do this, but its not a very good way to encourage participation from the
community. But I guess it is a particularly good way to discourage drive-by defect
reports.
</p>
        <img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=e31f3ad6-343d-4a2e-98a4-0e38a159b4c5" />
      </body>
      <title>Some thoughts on mono and Cocoa</title>
      <guid isPermaLink="false">http://www.milkcarton.com/blog/PermaLink,guid,e31f3ad6-343d-4a2e-98a4-0e38a159b4c5.aspx</guid>
      <link>http://www.milkcarton.com/blog/2010/07/05/Some+Thoughts+On+Mono+And+Cocoa.aspx</link>
      <pubDate>Mon, 05 Jul 2010 09:28:36 GMT</pubDate>
      <description>&lt;p&gt;
For the past week or so, I've been developing a couple of sample apps in &lt;a href="http://www.mono-project.com/"&gt;Mono&lt;/a&gt; with
Cocoa on my Mac. In that time, I've struggled quite a bit, and learned quite a bit.
One of the biggest things I've learned is things are much harder when you try and
mix-in paradimes for which things were not designed.
&lt;/p&gt;
&lt;p&gt;
Take for example &lt;a href="http://www.cocoadev.com/index.pl?NSTableViewTutorial"&gt;NSTableView&lt;/a&gt;.
Because &lt;a href="http://en.wikipedia.org/wiki/Objective-C"&gt;Objective-C&lt;/a&gt; is &lt;a href="http://en.wikipedia.org/wiki/Duck_typing"&gt;duck
typed&lt;/a&gt;, you set Delegate property of your table to &lt;em&gt;this&lt;/em&gt; (&lt;em&gt;self&lt;/em&gt; in
Objective-C) and implement the selectionDidChange method and you will get notified
when a row is selected.
&lt;/p&gt;
&lt;p&gt;
Because C# is not &lt;a href="http://en.wikipedia.org/wiki/Duck_typing"&gt;duck typed&lt;/a&gt;,
you have to &lt;a href="http://www.milkcarton.com/blog/2010/07/05/Databinding+To+An+NSTableView+With+A+MonoMac+App.aspx"&gt;write
a whole lot of ceremony code&lt;/a&gt; to get notified when a row is selected. And figuring
out that ceremony was a huge battle. I wouldn't have won the war without the help
of &lt;a href="http://twitter.com/moshakis"&gt; John Moshakis&lt;/a&gt;. Another thing thats not
supported is &lt;em&gt;Register&lt;/em&gt;ing a generic type, or setting a generic .NET type the
property of a Cocoa widget.
&lt;/p&gt;
&lt;p&gt;
That means the ceremony code has to be duplicated every time, for every different
type of object. I actually tried to make a generic version of my &lt;a href="http://www.milkcarton.com/blog/2010/07/05/Databinding+To+An+NSTableView+With+A+MonoMac+App.aspx"&gt;Databinding
to an NSTableView&lt;/a&gt; blog post, but I was thwarted by an "Invalid IL exception."
Hopefully this is just a defect, and not a limitation when dealing with Cocoa.
&lt;/p&gt;
&lt;p&gt;
I would file a defect on this issue with the mono project, but Novell requires you
to create an account to add a defect to their bug tracker. I can understand why they
want you to do this, but its not a very good way to encourage participation from the
community. But I guess it is a particularly good way to discourage drive-by defect
reports.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.milkcarton.com/blog/aggbug.ashx?id=e31f3ad6-343d-4a2e-98a4-0e38a159b4c5" /&gt;</description>
      <comments>http://www.milkcarton.com/blog/CommentView,guid,e31f3ad6-343d-4a2e-98a4-0e38a159b4c5.aspx</comments>
      <category>.NET</category>
      <category>Mac OS X</category>
      <category>Mono</category>
      <category>MonoMac</category>
    </item>
  </channel>
</rss>