<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kunugiken</title>
	<atom:link href="http://www.kunugiken.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kunugiken.com</link>
	<description>software design</description>
	<lastBuildDate>Tue, 06 Sep 2011 02:43:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simple Selectable Toolbar Class</title>
		<link>http://www.kunugiken.com/cocoa/simple-selectable-toolbar-class</link>
		<comments>http://www.kunugiken.com/cocoa/simple-selectable-toolbar-class#comments</comments>
		<pubDate>Sat, 15 Jan 2011 05:45:42 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=447</guid>
		<description><![CDATA[In many Cocoa applications you may see a very similar layout for the preferences window. It involves a selectable toolbar, but very inconveniently, Interface Builder does not provide a built-in way to create such a toolbar. Until just recently, I was using BWToolkit to create such a toolbar, but in the newest version of Interface [...]]]></description>
			<content:encoded><![CDATA[<p>In many Cocoa applications you may see a very similar layout for the preferences window.  It involves a selectable toolbar, but very inconveniently, Interface Builder does not provide a built-in way to create such a toolbar.  Until just recently, I was using <a href="http://www.brandonwalkin.com/bwtoolkit/">BWToolkit</a> to create such a toolbar, but in the newest version of Interface Builder, it seems to be broken (version 3.2.5 as of writing).  So here is a quick solution I came up with, that tries to use as little code as possible.  The only code is a small class (only two methods) called SelectableToolbar. <a href="http://files.kunugiken.com/Programs/SelectableToolbar.zip">Download it here</a></p>
<p>Include the class in your project, then create a new window in Interface Builder.  Add a NSToolbar to the window, and set the toolbar&#8217;s class to SelectableToolbar. <a href="http://blog.kunugiken.com/wp-content/uploads/2011/01/Screen-shot-2011-01-14-at-8.28.38-PM.png"><img class="alignnone size-full wp-image-451" title="Set class to SelectableToolbar" src="http://blog.kunugiken.com/wp-content/uploads/2011/01/Screen-shot-2011-01-14-at-8.28.38-PM.png" alt="" width="284" height="91" /></a><br />
Remove the default items from the toolbar and add new ones, being sure to set them as &#8216;Selectable&#8217;, and set their action to the change: method in the SelectableToolbar<a href="http://blog.kunugiken.com/wp-content/uploads/2011/01/Screen-shot-2011-01-14-at-9.00.11-PM.png"><img class="alignnone size-full wp-image-452" title="Set action to change:" src="http://blog.kunugiken.com/wp-content/uploads/2011/01/Screen-shot-2011-01-14-at-9.00.11-PM.png" alt="" width="414" height="112" /></a><br />
In the window, add a tab view, and make the number of tabs equal to the number of items in your toolbar, and set the tabs to be at the bottom.  Set your new tab view to resize with the window, position it in the top left corner and make it fill the whole window, also connect the SelectableToolbar&#8217;s tabview outlet to it.  Now, populate your tab view&#8217;s tabs with appropriate controls and whatnot.  When you finish a tab, select all its contents, and choose Layout &gt; Embed Objects In &gt; Custom View.  <a href="http://blog.kunugiken.com/wp-content/uploads/2011/01/Screen-shot-2011-01-14-at-8.31.42-PM.png"><img class="size-full wp-image-453 alignleft" title="Embed Objects In Custom View" src="http://blog.kunugiken.com/wp-content/uploads/2011/01/Screen-shot-2011-01-14-at-8.31.42-PM.png" alt="" width="147" height="179" /></a>This puts the contents of the tab in its own view, that the SelectableToolbar will use to determine the size of the window.  So position the view in the top left corner, and change it&#8217;s autosizing so that it stays in the top left corner. </p>
<div id="attachment_454" class="wp-caption alignright" style="width: 219px"><a href="http://blog.kunugiken.com/wp-content/uploads/2011/01/Screen-shot-2011-01-14-at-9.25.53-PM.png"><img class="size-full wp-image-454 " title="Example" src="http://blog.kunugiken.com/wp-content/uploads/2011/01/Screen-shot-2011-01-14-at-9.25.53-PM.png" alt="" width="209" height="197" /></a><p class="wp-caption-text">Completed Window (View from Interface Builder)</p></div>
<p>Keep in mind that, the size of the tab view and of the window doesn&#8217;t matter, so you can change it to help you lay things out, just keep the tab view in the top left corner. If you&#8217;ve set it up correctly, it should look something like to the right in Interface Builder<br />
<a href="http://files.kunugiken.com/Programs/Simple%20Selectable%20Toolbar%20Project.zip">Download the Sample Project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/cocoa/simple-selectable-toolbar-class/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling Pdftk for Snow Leopard</title>
		<link>http://www.kunugiken.com/os-x/compiling-pdftk-for-snow-leopard</link>
		<comments>http://www.kunugiken.com/os-x/compiling-pdftk-for-snow-leopard#comments</comments>
		<pubDate>Tue, 21 Sep 2010 02:24:31 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=423</guid>
		<description><![CDATA[I decided to look into different types of PDF software hoping to find some awesome PDF utility from linux that would be equally as awesome when I ran it on OS X.  Eventually I came across Pdftk.  It was a command-line utility that was based on a pdf libraries written in Java.  It seemed very [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to look into different types of PDF software hoping to find some awesome PDF utility from linux that would be equally as awesome when I ran it on OS X.  Eventually I came across <a title="Pdftk" href="http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/">Pdftk</a>.  It was a command-line utility that was based on a pdf libraries written in Java.  It seemed very interesting, and I couldn&#8217;t wait to try it out.  So I fired up good ol&#8217; <a title="Macports" href="http://www.macports.org/">macports</a> and &#8216;sudo port install pdftk&#8217; and&#8230;</p>

<div class="wp_codebox"><table><tr id="p4236"><td class="code" id="p423code6"><pre class="term" style="font-family:monospace;">.../usr/bin/ranlib: file: .libs/libgfortran.a(_dim_r16.o) has no symbols
/usr/bin/ranlib: file: .libs/libgfortran.a(_atan2_r16.o) has no symbols
/usr/bin/ranlib: file: .libs/libgfortran.a(_mod_r16.o) has no symbols
creating libgfortran.la
(cd .libs &amp;&amp; rm -f libgfortran.la &amp;&amp; ln -s ../libgfortran.la libgfortran.la)
make: *** [all] Error 2</pre></td></tr></table></div>

<p>arghh.. It fails to build gcc42 which is need for <a href="http://gcc.gnu.org/java/">GCJ</a> (A handy part of GCC that turns java class files into native machine code).  It seems to make sense that this utility would need it, being based on libraries written in Java? Okay, so I&#8217;ll just download GCC (it includes GCJ) and compile it myself.  I subversion&#8217;ed myself the newest copy of GCC&#8217;s source</p>

<div class="wp_codebox"><table><tr id="p4237"><td class="code" id="p423code7"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> checkout <span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>gcc.gnu.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>gcc<span style="color: #000000; font-weight: bold;">/</span>trunk <span style="color: #c20cb9; font-weight: bold;">gcc</span></pre></td></tr></table></div>

<p>I configured it to tell it where all my libraries were and where to install to (for me since I use macports this would be /opt/local), but not before installing its dependencies (libiconv, and mpfr), luckily these installed fine using macports. Then I ran make and waited&#8230;and waited..and waited for almost 3 HOURS!. sheesh.  Apparently compilers are complicated or something.  Anyway.. it was time to remember what I was doing and <a title="Pdftk's source" href="http://www.pdflabs.com/docs/build-pdftk/">download Pdftk&#8217;s source</a>.  I configured it to the correct paths once again, (so it can find the libraries it needs for GCJ and so forth).  I&#8217;m ready to make&#8230; and</p>

<div class="wp_codebox"><table><tr id="p4238"><td class="code" id="p423code8"><pre class="term" style="font-family:monospace;">gcj: error trying to exec 'ecj1': execvp: No such file or directory</pre></td></tr></table></div>

<p>What?? Okay after some googling I find out that actually GCJ doesn&#8217;t do the actual compiling of the java files into class files, it relies on some jar from eclipse that you can <a title="ecj" href="ftp://sourceware.org/pub/java/">download the latest one here</a> (warning ftp site) (Another pitfall here is that when downloading jar files your browser might append a .zip on the end, just delete the .zip, don&#8217;t try to unzip the file).  You can place that file anywhere (I put it in /opt/local/share/gcc-4.6.0/ and renamed it ecj.jar for simplicities sake).  It also needs a script called ecj1 with the contents as follows:</p>

<div class="wp_codebox"><table><tr id="p4239"><td class="code" id="p423code9"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
gij <span style="color: #660033;">-cp</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gcc-4.6.0<span style="color: #000000; font-weight: bold;">/</span>ecj.jar org.eclipse.jdt.internal.compiler.batch.GCCMain <span style="color: #800000;">${1+&quot;$@&quot;}</span></pre></td></tr></table></div>

<p>Of course change the path in the script to point to your ecj.jar file.  I put this script in /opt/local/bin, but you can put it in any folder in your <a title="Unix guide for the PATH environment variable" href="http://en.wikibooks.org/wiki/Guide_to_Unix/Environment_Variables#PATH">PATH</a>.  Okay now, back to pdftk&#8230;but things still aren&#8217;t going well.  Another make, although goes further, reveals that there is a problem with the makefile&#8217;s calling of gcjh, aww man.  Okay more googling produces a <a title="Patch for Pdftk" href="http://repository.slacky.eu/slackware-13.0/office/pdftk/1.41/src/pdftk-1.41-gcc-4.3.patch">patch for this problem</a>. I apply the patch with &#8220;patch -p0 &lt; patch-filename&#8221;.  The patch doesn&#8217;t apply without errors of course.  I had to fix these manually, which isn&#8217;t too difficult, you just look at the .rej files and you can understand fairly easily the change they are indicating, if not read up on patch files a bit. Okay so things are looking good now, another make and the thing builds all the way to the end&#8230;. almost.</p>

<div class="wp_codebox"><table><tr id="p42310"><td class="code" id="p423code10"><pre class="bash" style="font-family:monospace;">multiple definition of <span style="color: #000000; font-weight: bold;">`</span>java resource .dummy<span style="color: #ff0000;">'</span></pre></td></tr></table></div>

<p>It fails to link all the compiled files together&#8230;  Argh&#8230; Okay so at least <a title="GCJ Bug" href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43302">this is a know bug</a> so there must be a fix right?  Well there is a <a title="temp fix for GCJ bug" href="http://stackoverflow.com/questions/2567230/gcj-creates-duplicate-dummy-symbol">temporary fix</a>, that is to use the objcopy command from binutils to force the dummy resource to be local, but alas objcopy doesn&#8217;t seem to work on OS X, I even built it from the newest version of the source and it still doesn&#8217;t work.  The only way I found to fix this was to use a hex or text editor to rename the dummy resource.  That&#8217;s exactly what I ended up doing after failing to write a script to do it (all of the scripts I wrote ended up corrupting the file somehow).  I opened up all the .o files in the project with <a title="Smultron" href="http://smultron.sourceforge.net/">smultron</a> and did a find and replace on each one (find: dummy replace: random 5-character string).  This is not the desired way of doing this since there are literally hundreds of them (I may be exaggerating).</p>
<p>Holy crap, that was a lot of work to compile pdftk.  If you&#8217;re planning to do the same I sympathise with you, (and let me know if you need any help since I&#8217;ve already done it.)  Although, for those of you out there with a 64-bit snow leopard system you can download this package I made of my binaries.  (they install to /usr/local/).  <br />
<a title="Pdftk for 64-bit Snow Leopard" href="http://files.kunugiken.com/Pdftk_for_OSX.pkg.gz">Download the Package</a></p>
<p>I hope this helps someone not go through the same frustration I did.  If you have any issues with the package or compiling it.  <a title="mail me!" href="mailto:shimijimi@kunugiken.com">Let me know I can lend a hand.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/os-x/compiling-pdftk-for-snow-leopard/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Kunugiken Software Release: Pianopub</title>
		<link>http://www.kunugiken.com/site-news/kunugiken-software-release-pianopub</link>
		<comments>http://www.kunugiken.com/site-news/kunugiken-software-release-pianopub#comments</comments>
		<pubDate>Fri, 10 Sep 2010 07:13:55 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Site News]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=406</guid>
		<description><![CDATA[Pianopub is a Pandora internet radio player.  It lets you manage and listen to your stations in a native Cocoa application.  It is a port of Pianobar, please support these brilliant people.  It has built in support for the apple remote, and the media keys.  It also posts notifications of songs using growl. Listening to [...]]]></description>
			<content:encoded><![CDATA[<p>Pianopub is a Pandora internet radio player.  It lets you manage and listen to your stations in a native Cocoa application.  It is a port of <a href="http://github.com/PromyLOPh/pianobar">Pianobar</a>, please support these brilliant people.  It has built in support for the apple remote, and the media keys.  It also posts notifications of songs using growl. Listening to Pandora, I felt like I wanted to control it like iTunes, and also I wanted to not have to have my browser open just to listen to it, because I might close it accidentally.  Then when I ran across Pianobar, I was thrilled and delighted, but I just wished it was more user-friendly, and easier to control.  So thats why I made this, so now more people can enjoy the benefits of Pianobar in a convenient package.  Why not check it out yourself, its free! <a href="http://dev.kunugiken.com/Pianopub">Download Here</a>.  If you like it, or have ideas for new features, let me know about it in the comments.</p>
<div class="wp-caption alignnone" style="width: 373px"><a href="http://dev.kunugiken.com/Pianopub/shot_expanded.png"><img class="   " title="Pianopub" src="http://dev.kunugiken.com/Pianopub/shot_expanded.png" alt="" width="363" height="181" /></a><p class="wp-caption-text">Pianopub in Action</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/site-news/kunugiken-software-release-pianopub/feed</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>HowTo: Disappearing NSTable Buttons</title>
		<link>http://www.kunugiken.com/cocoa/howto-disappearing-nstable-buttons</link>
		<comments>http://www.kunugiken.com/cocoa/howto-disappearing-nstable-buttons#comments</comments>
		<pubDate>Wed, 11 Aug 2010 04:40:28 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=367</guid>
		<description><![CDATA[Recently I was working on a project where I wanted a certain effect. This was that I wanted the user to be able to delete items out of a table by clicking on the item and not having to add some button somewhere else to do it. So the answer was to put a button [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_369" class="wp-caption alignleft" style="width: 221px"><a href="http://blog.kunugiken.com/wp-content/uploads/2010/07/Screen-shot-2010-07-21-at-1.20.40-AM.png"><img class="size-full wp-image-369  " title="Disappearing NSTable Buttons" src="http://blog.kunugiken.com/wp-content/uploads/2010/07/Screen-shot-2010-07-21-at-1.20.40-AM.png" alt="Disappearing NSTable Buttons" width="211" height="200" /></a><p class="wp-caption-text">Completed Project</p></div>
<p>Recently I was working on a project where I wanted a certain effect.  This was that I wanted the user to be able to delete items out of a table by clicking on the item and not having to add some button somewhere else to do it.  So the answer was to put a button on the table to delete it.  That was simple enough, just make a table with button cells, but it didn&#8217;t look very nice, it showed all the button when you could only delete one at a time.  So thus, I decided to make the buttons only appear on the selected table items.  Its simple, functional, and you can do it too if you just follow this short guide.</p>
<p>To tackle this problem, there are two &#8220;hacks&#8221; that we need to do.  First, we have to somehow make the NSButtonCell hide itself.  Next, we have to keep track of which row is selected, and tie that information back to our buttons.  To accomplish the first task, will tie the button being hidden to it&#8217;s enabled value, since this way is easier then creating a new binding, and it doesn&#8217;t matter is the button is disabled if it&#8217;s hidden anyway.  Subclass NSButtonCell and override this method with this code.</p>

<div class="wp_codebox"><table><tr id="p36713"><td class="code" id="p367code13"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> drawWithFrame<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>NSRect<span style="color: #009900;">&#41;</span>cellFrame inView<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>NSView<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>controlView
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>self isEnabled<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#91;</span>super drawWithFrame<span style="color: #339933;">:</span>cellFrame inView<span style="color: #339933;">:</span>controlView<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In interface builder, drag a NSButtonCell to one of the columns of your NSTableView.  (Apple hides it as a &#8216;Check Box Cell&#8217;, see below, you have to change the type to &#8216;Momentary Push In&#8217;).</p>
<div id="attachment_377" class="wp-caption alignleft" style="width: 263px"><a href="http://blog.kunugiken.com/wp-content/uploads/2010/08/Screen-shot-2010-08-10-at-7.33.17-PM.png"><img class="size-full wp-image-377  " title="Interface Builder Check Box Cell" src="http://blog.kunugiken.com/wp-content/uploads/2010/08/Screen-shot-2010-08-10-at-7.33.17-PM.png" alt="Interface Builder Check Box Cell (NSButonCell)" width="253" height="43" /></a><p class="wp-caption-text">Check Box Cell (NSButtonCell)</p></div>
<div id="attachment_378" class="wp-caption alignleft" style="width: 282px"><a href="http://blog.kunugiken.com/wp-content/uploads/2010/08/Screen-shot-2010-08-10-at-8.02.35-PM.png"><img class="size-full wp-image-378" title="HidingButtonCell" src="http://blog.kunugiken.com/wp-content/uploads/2010/08/Screen-shot-2010-08-10-at-8.02.35-PM.png" alt="Setting the Class to HidingButtonCell" width="272" height="52" /></a><p class="wp-caption-text">Setting the Class to HidingButtonCell</p></div>
<p>Change the class to your custom subclass. Next we need to somehow get the data in a form we can bind to the button&#8217;s enabled key.  There are potentially a couple ways to do this, but I decided to subclass NSTableView, and override this method.</p>

<div class="wp_codebox"><table><tr id="p36714"><td class="code" id="p367code14"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>selectRowIndexes<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSIndexSet <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>indexes byExtendingSelection<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>BOOL<span style="color: #009900;">&#41;</span>extend
<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#91;</span>super selectRowIndexes<span style="color: #339933;">:</span>indexes byExtendingSelection<span style="color: #339933;">:</span>extend<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>controller setSelectionIndex<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>indexes firstIndex<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>controller arrangedObjects<span style="color: #009900;">&#93;</span> count<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>controller arrangedObjects<span style="color: #009900;">&#93;</span> objectAtIndex<span style="color: #339933;">:</span>i<span style="color: #009900;">&#93;</span> setObject<span style="color: #339933;">:</span>
			<span style="color: #009900;">&#91;</span>NSNumber numberWithInt<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>indexes firstIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> i<span style="color: #009900;">&#93;</span> forKey<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;enabled&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Of, course this way of doing this assumes you&#8217;re binding to an NSArray of NSMutableDictionaries.  Next, back in Interface Builder we can bind the column to the new data that&#8217;s going to be generated with that method.  And thats it enjoy you&#8217;re disappearing buttons.  If you want the button to delete the row, like mine, just connect the NSButtonCell&#8217;s action to the NSArrayController&#8217;s remove: method. If I made any mistakes, or made anything unclear, please leave a comment.  For a closer look, <a title="Disappearing Buttons Xcode Project" href="http://files.kunugiken.com/Programs/Disappearing%20Buttons.zip">Download the Xcode Project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/cocoa/howto-disappearing-nstable-buttons/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remi&#8217;s Chat App</title>
		<link>http://www.kunugiken.com/cocoa/remis-chat-app</link>
		<comments>http://www.kunugiken.com/cocoa/remis-chat-app#comments</comments>
		<pubDate>Mon, 19 Jul 2010 06:46:59 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=350</guid>
		<description><![CDATA[As promised, here is some example code for the iPhone using ThoMoNetworking. I call it Remi&#8217;s Chat App. The mobile companion to Remi&#8217;s Chat Program. Sorry it took me so long to put it up.  Some things to note: It interfaces with Remi&#8217;s Chat Program in everything except that iOS doesn&#8217;t support the rich text. [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here is some example code for the iPhone using ThoMoNetworking.  I call it Remi&#8217;s Chat App.  The mobile companion to <a href="http://blog.kunugiken.com/?p=339">Remi&#8217;s Chat Program</a>.</p>
<p><a href="http://blog.kunugiken.com/wp-content/uploads/2010/07/Screen-shot-2010-07-18-at-11.28.38-PM.png"><img class="alignnone size-full wp-image-353" title="Remi's Chat App" src="http://blog.kunugiken.com/wp-content/uploads/2010/07/Screen-shot-2010-07-18-at-11.28.38-PM.png" alt="" width="248" height="462" /></a><br />
Sorry it took me so long to put it up.  Some things to note: It interfaces with <a href="http://blog.kunugiken.com/?p=339">Remi&#8217;s Chat Program</a> in everything except that iOS doesn&#8217;t support the rich text.  You may notice if you download the project that I created a file called NSPatches, this was to allow for the iOS to properly unarchive some classes that it doesn&#8217;t have, most notably NSFont.  Other then that, from what I can tell ThoMoNetworking works flawlessly on iOS.  The only thing I couldn&#8217;t test was from iOS to iOS, since I lacked two iOS devices, but from iOS to OS X worked great, so I would assume it would work fine.  So here is the bulk of the code for you to peruse, and you can download the project underneath, enjoy!</p>
<p>P.S.  Let me know if anybody runs into any issues with the code, I may be able to resolve them easily, since some crashes might just be due to iOS not having certain clases that OS X has, which a simple appending to the NSPatches file should fix.</p>

<div class="wp_codebox"><table><tr id="p35016"><td class="code" id="p350code16"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  Remi_s_Chat_AppViewController.m</span>
<span style="color: #666666; font-style: italic;">//  Remi's Chat App</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  Created by Remi Bernotavicius on 7/18/10.</span>
<span style="color: #666666; font-style: italic;">//  Copyright __MyCompanyName__ 2010. All rights reserved.</span>
<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
<span style="color: #339933;">#import &quot;Remi_s_Chat_AppViewController.h&quot;</span>
&nbsp;
@implementation Remi_s_Chat_AppViewController
&nbsp;
<span style="color: #808080; font-style: italic;">/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.</span>
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>viewDidLoad <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#91;</span>super viewDidLoad<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	myServer <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>ThoMoServerStub alloc<span style="color: #009900;">&#93;</span> initWithProtocolIdentifier<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;remischat&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer setDelegate<span style="color: #339933;">:</span>self<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer start<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	myClient <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>ThoMoClientStub alloc<span style="color: #009900;">&#93;</span> initWithProtocolIdentifier<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;remischat&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myClient setDelegate<span style="color: #339933;">:</span>self<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myClient start<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>UIApplication sharedApplication<span style="color: #009900;">&#93;</span> setDelegate<span style="color: #339933;">:</span>self<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>applicationWillTerminate<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>UIApplication <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>application
<span style="color: #009900;">&#123;</span>
	NSMutableAttributedString<span style="color: #339933;">*</span> temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSFullUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> stringByAppendingString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot; disconnected&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer sendToAllClients<span style="color: #339933;">:</span>temp<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>server<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>ThoMoServerStub <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>theServer acceptedConnectionFromClient<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>aClientIdString<span style="color: #339933;">;</span>
<span style="color: #009900;">&#123;</span>
	NSMutableAttributedString<span style="color: #339933;">*</span> temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSFullUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> stringByAppendingString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot; connected&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer send<span style="color: #339933;">:</span>temp toClient<span style="color: #339933;">:</span>aClientIdString<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>didReceiveMemoryWarning <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Releases the view if it doesn't have a superview.</span>
    <span style="color: #009900;">&#91;</span>super didReceiveMemoryWarning<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Release any cached data, images, etc that aren't in use.</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>viewDidUnload <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Release any retained subviews of the main view.</span>
	<span style="color: #666666; font-style: italic;">// e.g. self.myOutlet = nil;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>textFieldDidBeginEditing<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>UITextField <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>textField
<span style="color: #009900;">&#123;</span>
	CGRect newFrame <span style="color: #339933;">=</span> self.<span style="color: #202020;">view</span>.<span style="color: #202020;">frame</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>UIApplication sharedApplication<span style="color: #009900;">&#93;</span> statusBarOrientation<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span> UIInterfaceOrientationPortrait
		<span style="color: #339933;">||</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>UIApplication sharedApplication<span style="color: #009900;">&#93;</span> statusBarOrientation<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> UIInterfaceOrientationPortraitUpsideDown<span style="color: #009900;">&#41;</span>
		newFrame.<span style="color: #202020;">size</span>.<span style="color: #202020;">height</span> <span style="color: #339933;">-=</span> <span style="color: #0000dd;">216</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span>
		newFrame.<span style="color: #202020;">size</span>.<span style="color: #202020;">height</span> <span style="color: #339933;">-=</span> <span style="color: #0000dd;">162</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#91;</span>UIView beginAnimations<span style="color: #339933;">:</span>nil context<span style="color: #339933;">:</span>NULL<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#91;</span>UIView setAnimationBeginsFromCurrentState<span style="color: #339933;">:</span>YES<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#91;</span>UIView setAnimationDuration<span style="color: #339933;">:</span><span style="color:#800080;">0.3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#91;</span>self.<span style="color: #202020;">view</span> setFrame<span style="color: #339933;">:</span>newFrame<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#91;</span>UIView commitAnimations<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span>sendMessage<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>sender
<span style="color: #009900;">&#123;</span>
	NSMutableAttributedString<span style="color: #339933;">*</span> temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSFullUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> stringByAppendingString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;: &quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span>toSend.<span style="color: #202020;">text</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#91;</span>myServer sendToAllClients<span style="color: #339933;">:</span>temp<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	toSend.<span style="color: #202020;">text</span> <span style="color: #339933;">=</span> @<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>textFieldDidEndEditing<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>UITextField <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>textField
<span style="color: #009900;">&#123;</span>
	CGRect newFrame <span style="color: #339933;">=</span> self.<span style="color: #202020;">view</span>.<span style="color: #202020;">frame</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>UIApplication sharedApplication<span style="color: #009900;">&#93;</span> statusBarOrientation<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span> UIInterfaceOrientationPortrait
		<span style="color: #339933;">||</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>UIApplication sharedApplication<span style="color: #009900;">&#93;</span> statusBarOrientation<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> UIInterfaceOrientationPortraitUpsideDown<span style="color: #009900;">&#41;</span>
		newFrame.<span style="color: #202020;">size</span>.<span style="color: #202020;">height</span> <span style="color: #339933;">+=</span> <span style="color: #0000dd;">216</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span>
		newFrame.<span style="color: #202020;">size</span>.<span style="color: #202020;">height</span> <span style="color: #339933;">+=</span> <span style="color: #0000dd;">162</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#91;</span>UIView beginAnimations<span style="color: #339933;">:</span>nil context<span style="color: #339933;">:</span>NULL<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#91;</span>UIView setAnimationBeginsFromCurrentState<span style="color: #339933;">:</span>YES<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#91;</span>UIView setAnimationDuration<span style="color: #339933;">:</span><span style="color:#800080;">0.3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#91;</span>self.<span style="color: #202020;">view</span> setFrame<span style="color: #339933;">:</span>newFrame<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#91;</span>UIView commitAnimations<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>server<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>ThoMoServerStub <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>theServer didReceiveData<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>theData fromClient<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>aClientIdString <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>client<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>ThoMoClientStub <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>theClient didReceiveData<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>theData fromServer<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>aServerIdString<span style="color: #339933;">;</span>
<span style="color: #009900;">&#123;</span>
	NSMutableAttributedString<span style="color: #339933;">*</span> temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithAttributedString<span style="color: #339933;">:</span>theData<span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	history.<span style="color: #202020;">text</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>history.<span style="color: #202020;">text</span> stringByAppendingString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>temp <span style="color: #993333;">string</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#91;</span>history scrollRangeToVisible<span style="color: #339933;">:</span>NSMakeRange<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>history.<span style="color: #202020;">text</span> length<span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>dealloc <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#91;</span>super dealloc<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@end</pre></td></tr></table></div>

<p><a href="http://files.kunugiken.com/Programs/Remi's%20Chat%20App.zip">Download the Xcode Project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/cocoa/remis-chat-app/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ThoMoNetworking Framework</title>
		<link>http://www.kunugiken.com/cocoa/thomonetworking-framework</link>
		<comments>http://www.kunugiken.com/cocoa/thomonetworking-framework#comments</comments>
		<pubDate>Tue, 08 Jun 2010 09:59:45 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=339</guid>
		<description><![CDATA[I happened to stumble upon an amazing framework called ThoMoNetworking. It takes the complicated task of networking in Cocoa and makes it extremely easy. Basically it lets you define your own protocol and connects to other instances of it on the network automatically using bonjour. Then to send data it allows you to send objects. [...]]]></description>
			<content:encoded><![CDATA[<p>I happened to stumble upon an amazing framework called <a title="ThoMoNetworking Framework Website" href="http://hci.rwth-aachen.de/thomonet" target="_blank">ThoMoNetworking</a>.  It takes the complicated task of networking in Cocoa and makes it extremely easy.  Basically it lets you define your own protocol and connects to other instances of it on the network automatically using bonjour.  Then to send data it allows you to send objects.  The potential from this framework is huge, especially since it works on both iPhone OS and Mac OS.  It is incredibly simple, check out their website for how to use it, it is outlined in its full simplistic beauty.</p>
<p>With such a powerful framework at my disposal, I decided to test it out.  I wanted to see just how easy it would be to create my own ad-hoc chatting program.  I&#8217;ve included the source as well so you can test out the framework for yourselves.</p>
<p>I give you, Remi&#8217;s Chat Program</p>
<p><a href="http://blog.kunugiken.com/wp-content/uploads/2010/06/Remis-Chat-Program-SC.png"><img class="alignnone size-full wp-image-340" title="Remi's Chat Program Screenshot" src="http://blog.kunugiken.com/wp-content/uploads/2010/06/Remis-Chat-Program-SC.png" alt="Remi's Chat Program" width="313" height="302" /></a></p>
<p>Since ThoMoNetworking lets you send any object, I was able to send NSAttributedString objects, so the text&#8217;s color and font are preserved.  I was also able to include recalling previously sent messages with the arrow keys (like in the terminal) and growl support as a superfluous features.  This seemingly complicated program is actually very little code.</p>

<div class="wp_codebox"><table><tr id="p33918"><td class="code" id="p339code18"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  Remi_s_Chat_ProgramAppDelegate.m</span>
<span style="color: #666666; font-style: italic;">//  Remi's Chat Program</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  Created by Remi Bernotavicius on 6/1/10.</span>
<span style="color: #666666; font-style: italic;">//  Copyright 2010 __MyCompanyName__. All rights reserved.</span>
<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
<span style="color: #339933;">#import &quot;Remi_s_Chat_ProgramAppDelegate.h&quot;</span>
&nbsp;
@implementation Remi_s_Chat_ProgramAppDelegate
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>NSDictionary <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> registrationDictionaryForGrowl <span style="color: #009900;">&#123;</span>
	NSArray <span style="color: #339933;">*</span>array <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>NSArray arrayWithObjects<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;new message&quot;</span><span style="color: #339933;">,</span> nil<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    NSDictionary <span style="color: #339933;">*</span>dict <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>NSDictionary dictionaryWithObjectsAndKeys<span style="color: #339933;">:</span>
                          <span style="color: #009900;">&#91;</span>NSNumber numberWithInt<span style="color: #339933;">:</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                          @<span style="color: #ff0000;">&quot;TicketVersion&quot;</span><span style="color: #339933;">,</span>
                          array<span style="color: #339933;">,</span>
                          @<span style="color: #ff0000;">&quot;AllNotifications&quot;</span><span style="color: #339933;">,</span>
                          array<span style="color: #339933;">,</span>
                          @<span style="color: #ff0000;">&quot;DefaultNotifications&quot;</span><span style="color: #339933;">,</span>
                          nil<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> dict<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> growlAlert<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>message title<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>title<span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#91;</span>GrowlApplicationBridge notifyWithTitle<span style="color: #339933;">:</span>title
								description<span style="color: #339933;">:</span>message
						   notificationName<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;new message&quot;</span>
								   iconData<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSApplication sharedApplication<span style="color: #009900;">&#93;</span> applicationIconImage<span style="color: #009900;">&#93;</span> TIFFRepresentation<span style="color: #009900;">&#93;</span>
								   priority<span style="color: #339933;">:</span><span style="color: #0000dd;">0</span>
								   isSticky<span style="color: #339933;">:</span>NO
							   clickContext<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;bringFrontContext&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>applicationDidFinishLaunching<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSNotification <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>aNotification
<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#91;</span>GrowlApplicationBridge setGrowlDelegate<span style="color: #339933;">:</span>self<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	myServer <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>ThoMoServerStub alloc<span style="color: #009900;">&#93;</span> initWithProtocolIdentifier<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;remischat&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer setDelegate<span style="color: #339933;">:</span>self<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer start<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	myClient <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>ThoMoClientStub alloc<span style="color: #009900;">&#93;</span> initWithProtocolIdentifier<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;remischat&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myClient setDelegate<span style="color: #339933;">:</span>self<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myClient start<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSApplication sharedApplication<span style="color: #009900;">&#93;</span> setDelegate<span style="color: #339933;">:</span>self<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	previousChats <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableArray alloc<span style="color: #009900;">&#93;</span> init<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	current <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>server<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>ThoMoServerStub <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>theServer acceptedConnectionFromClient<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>aClientIdString<span style="color: #339933;">;</span>
<span style="color: #009900;">&#123;</span>
	NSMutableAttributedString<span style="color: #339933;">*</span> temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSFullUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> stringByAppendingString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot; connected&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp addAttributes<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSDictionary dictionaryWithObjectsAndKeys<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSFont boldSystemFontOfSize<span style="color: #339933;">:</span><span style="color: #0000dd;">12</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> NSFontAttributeName<span style="color: #339933;">,</span> nil<span style="color: #009900;">&#93;</span> range<span style="color: #339933;">:</span>NSMakeRange<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>temp length<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer send<span style="color: #339933;">:</span>temp toClient<span style="color: #339933;">:</span>aClientIdString<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>dealloc
<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#91;</span>previousChats release<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>super dealloc<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>retreat
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>current <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #009900;">&#91;</span>previousChats count<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> 	<span style="color: #009900;">&#123;</span> 		current<span style="color: #339933;">++;</span> 		<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>toSend textStorage<span style="color: #009900;">&#93;</span> setAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>previousChats objectAtIndex<span style="color: #339933;">:</span>current<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>current <span style="color: #339933;">==</span> <span style="color: #009900;">&#91;</span>previousChats count<span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> 			<span style="color: #009900;">&#91;</span>previousChats removeLastObject<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 	<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>advance <span style="color: #009900;">&#123;</span> 	 	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>current <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#91;</span>previousChats count<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>current <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #009900;">&#91;</span>previousChats count<span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#91;</span>previousChats addObject<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>toSend attributedString<span style="color: #009900;">&#93;</span> copy<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		current<span style="color: #339933;">--;</span>
		<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>toSend textStorage<span style="color: #009900;">&#93;</span> setAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>previousChats objectAtIndex<span style="color: #339933;">:</span>current<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>windowDidBecomeKey<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSNotification <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>notification
<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#91;</span>mainWindow makeFirstResponder<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>toSend superview<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span>sendMessage<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>sender
<span style="color: #009900;">&#123;</span>
	NSMutableAttributedString<span style="color: #339933;">*</span> temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSFullUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> stringByAppendingString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;: &quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>toSend attributedString<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#91;</span>previousChats addObject<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>toSend attributedString<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>previousChats count<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> <span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span>
		current <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>previousChats count<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#91;</span>previousChats removeObjectAtIndex<span style="color: #339933;">:</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	NSString<span style="color: #339933;">*</span> t <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>temp <span style="color: #993333;">string</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>t substringWithRange<span style="color: #339933;">:</span>NSMakeRange<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>t length<span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> isEqual<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer sendToAllClients<span style="color: #339933;">:</span>temp<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>toSend textStorage<span style="color: #009900;">&#93;</span> setAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> growlNotificationWasClicked<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>clickContext<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSApplication sharedApplication<span style="color: #009900;">&#93;</span> activateIgnoringOtherApps<span style="color: #339933;">:</span>YES<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>server<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>ThoMoServerStub <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>theServer didReceiveData<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>theData fromClient<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>aClientIdString <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>client<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>ThoMoClientStub <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>theClient didReceiveData<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>theData fromServer<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>aServerIdString<span style="color: #339933;">;</span>
<span style="color: #009900;">&#123;</span>
	NSMutableAttributedString<span style="color: #339933;">*</span> temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>history attributedString<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span>theData<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>history textStorage<span style="color: #009900;">&#93;</span> setAttributedString<span style="color: #339933;">:</span>temp<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#91;</span>history scrollRangeToVisible<span style="color: #339933;">:</span>NSMakeRange<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>history textStorage<span style="color: #009900;">&#93;</span> length<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#91;</span>mainWindow isKeyWindow<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSApplication sharedApplication<span style="color: #009900;">&#93;</span> requestUserAttention<span style="color: #339933;">:</span>NSCriticalRequest<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#91;</span>self growlAlert<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>NSAttributedString<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>theData <span style="color: #993333;">string</span><span style="color: #009900;">&#93;</span> title<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;New Message&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>NSApplicationTerminateReply<span style="color: #009900;">&#41;</span>applicationShouldTerminate<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSApplication <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>sender
<span style="color: #009900;">&#123;</span>
	NSMutableAttributedString<span style="color: #339933;">*</span> temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSMutableAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSFullUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> stringByAppendingString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot; disconnected&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp appendAttributedString<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSAttributedString alloc<span style="color: #009900;">&#93;</span> initWithString<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#93;</span> autorelease<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>temp addAttributes<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSDictionary dictionaryWithObjectsAndKeys<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSFont boldSystemFontOfSize<span style="color: #339933;">:</span><span style="color: #0000dd;">12</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> NSFontAttributeName<span style="color: #339933;">,</span> nil<span style="color: #009900;">&#93;</span> range<span style="color: #339933;">:</span>NSMakeRange<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>temp length<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>myServer sendToAllClients<span style="color: #339933;">:</span>temp<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> NSTerminateNow<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@end</pre></td></tr></table></div>

<p><a title="Remi's Chat Program Xcode Project" href="http://files.kunugiken.com/Programs/Remi's%20Chat%20Program.zip" target="_self">Download the Xcode Project</a></p>
<p>Let me know if there are any issues with the source, or if you would like to see more, like an iPhone OS example, just post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/cocoa/thomonetworking-framework/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New From Kunugiken WikiTyper</title>
		<link>http://www.kunugiken.com/cocoa/new-from-kunugiken-wikityper</link>
		<comments>http://www.kunugiken.com/cocoa/new-from-kunugiken-wikityper#comments</comments>
		<pubDate>Sun, 16 May 2010 02:53:31 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=327</guid>
		<description><![CDATA[I was playing the fabulous typing game TypeRacer when I thought that it would be fun to type some sort of other text. I decided to try making my own typing program. So I threw together this new typing game for OS X that lets you type random paragraphs of text from wikipedia. Its absolutely [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing the fabulous typing game <a href="http://play.typeracer.com/">TypeRacer</a> when I thought that it would be fun to type some sort of other text.  I decided to try making my own typing program.  So I threw together this new typing game for OS X that lets you type random paragraphs of text from wikipedia.  Its absolutely free, try downloading it here <a href="http://dev.kunugiken.com/WikiTyper">Download Page</a>.</p>
<div class="wp-caption alignnone" style="width: 585px"><a href="http://dev.kunugiken.com/WikiTyper"><img title="WikiTyper Screenshot" src="http://dev.kunugiken.com/WikiTyper/wikityper_screenshot.png" alt="" width="575" height="485" /></a><p class="wp-caption-text">WikiTyper in Action</p></div>
<p>If you have any comments on the game please post them below.  Some things I know are not working and I might fix in the future if people ask about them.  The words per minute is actual words per minute not the correct wpm, (if anyone knows the formula?)  Also occasionally it will display characters that you cannot type, but I couldn&#8217;t find a way to remedy that efficiently.  Finally, for those of you Linux and Windows users, a Java port is being made by someone else.  I will post a link if/when it is finished.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/cocoa/new-from-kunugiken-wikityper/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cocoa: Making Properties KVO Compliant</title>
		<link>http://www.kunugiken.com/cocoa/cocoa-making-methods-kvc-compliant</link>
		<comments>http://www.kunugiken.com/cocoa/cocoa-making-methods-kvc-compliant#comments</comments>
		<pubDate>Sun, 15 Nov 2009 04:53:13 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=278</guid>
		<description><![CDATA[In Cocoa KVO or Key-Value-Observing compliant means that the value of a certain object sends notifications out when its value has been changed to an observer. An example would be values stored in a NSMutableDictionary or NSMutableArray. Since they are KVO compliant, you can bind something to a value in one of these objects, and [...]]]></description>
			<content:encoded><![CDATA[<p>In Cocoa KVO or Key-Value-Observing compliant means that the value of a certain object sends notifications out when its value has been changed to an observer.  An example would be values stored in a NSMutableDictionary or NSMutableArray.  Since they are KVO compliant, you can bind something to a value in one of these objects, and will be updated automatically, no glue code required.  Although not all objects have their values KVO compliant and this can cause problems for example when trying to bind to them in Interface Builder.  A good example can be seen with NSDocument&#8217;s documentName.  Notice you can bind an object&#8217;s value to documentName, but if the documentName changes, this value does not update.  The way to fix this, is to subclass NSDocument and send out notifications whenever documentName is changed.  A class-dump of NSDocument reveals the -(BOOL)_setDocumentName:(NSString*)name method.  All you have to do is add this method to your NSDocument subclass</p>

<div class="wp_codebox"><table><tr id="p27820"><td class="code" id="p278code20"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>_setDisplayName<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>name
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//Hack Display Name to make KVO Compliant</span>
	<span style="color: #009900;">&#91;</span>self willChangeValueForKey<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;displayName&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>YourClassNameHere<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>super _setDisplayName<span style="color: #339933;">:</span>name<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>self didChangeValueForKey<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;displayName&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And that should be it.  Note: I changed the method&#8217;s return type to void because otherwise it will create an error in the console about KVO compliant methods not being able to return anything other then void.</p>
<p>Also note that this is for read-only binding, to do a binding where you can change the value you have to implement and expose a new binding programmatically.</p>
<p><a href="http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html">Apple&#8217;s Documentation on KVO</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/cocoa/cocoa-making-methods-kvc-compliant/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fixing Old Printer Drivers to Work in Snow Leopard</title>
		<link>http://www.kunugiken.com/personal/fixing-old-printer-drivers-to-work-in-snow-leopard</link>
		<comments>http://www.kunugiken.com/personal/fixing-old-printer-drivers-to-work-in-snow-leopard#comments</comments>
		<pubDate>Thu, 03 Sep 2009 18:40:12 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=273</guid>
		<description><![CDATA[The upgrade to snow leopard may be leaving some of you with not working printers. When I upgraded I could no longer print to my Xerox Workcentre Pro 238. The thing it seems is that snow leopard deletes all of your old PPDs and printer drivers. I had to download and install the driver again. [...]]]></description>
			<content:encoded><![CDATA[<p>The upgrade to snow leopard may be leaving some of you with not working printers.  When I upgraded I could no longer print to my Xerox Workcentre Pro 238.  The thing it seems is that snow leopard deletes all of your old PPDs and printer drivers.  I had to download and install the driver again.  Then alas, after doing so, the printer failed to function, it gave me the error message &#8220;The printer software was installed incorrectly. Please reinstall the printer’s software or contact the manufacturer for assistance.&#8221;  </p>
<p>After researching the error, I came to the conclusion that it has to do with snow leopard upgrading CUPS.  The newest version of CUPS, I read, requires that all the drivers&#8217; files be owned by root.  After investigating I found that Xerox&#8217;s PPD&#8217;s and plugins were NOT owned by root and thus causing the problem.  To remedy this problem just type this command into the terminal:</p>
<p>sudo chown -R root:admin /Library/Printers</p>
<p>(The command might take a while to run.) This owns the /Library/Printers folder and everything in it to root, this could potentially fix many different printer software to work with snow leopard since it can effect pretty much any printer driver.  So if you&#8217;re having problems try giving this a shot.  Good luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/personal/fixing-old-printer-drivers-to-work-in-snow-leopard/feed</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Snow Leopard and Close to Instant Gmail Contact Sync</title>
		<link>http://www.kunugiken.com/cocoa/snow-leopard-and-close-to-instant-gmail-contact-sync</link>
		<comments>http://www.kunugiken.com/cocoa/snow-leopard-and-close-to-instant-gmail-contact-sync#comments</comments>
		<pubDate>Tue, 01 Sep 2009 03:14:04 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=236</guid>
		<description><![CDATA[I&#8217;m sure many of you are aware that Apple has just released their newest OS X update called Snow Leopard, I was lucky enough to get my hands on a copy already. One very interesting feature of this update is the support for syncing your contacts in Address Book.app with Gmail&#8217;s contacts. Through Gmail, you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure many of you are aware that Apple has just released their newest OS X update called Snow Leopard, I was lucky enough to get my hands on a copy already.  One very interesting feature of this update is the support for syncing your contacts in Address Book.app with Gmail&#8217;s contacts.  Through Gmail, you can already sync your contacts to your iPhone thanks to <a href="http://www.google.com/mobile/products/sync.html#p=default">Google Sync</a>&#8216;s MS Exchange servers.  With the these two services combined you can have your contacts on your phone synced to your computer and vice-versa fairly instantly without MobileMe. The problem I was having was that this service didn&#8217;t do quite instant enough for my taste, here&#8217;s how you enable the sync, and how you can tweak it to make it even closer to instant.</p>
<p>First enable Gmail Contacts sync in Address Book by clicking Address Book > Preferences&#8230; > Accounts.  Then click &#8220;On My Mac&#8221;, and then check the box next to synchronize with Google. <img src="http://blog.kunugiken.com/wp-content/uploads/2009/08/Screen-shot-2009-08-31-at-5.09.18-PM.png" alt="Enabling Google Sync in Address Book in Snow Leopard" title="Enabling Google Sync in Address Book in Snow Leopard" width="580" height="522" class="size-full wp-image-237" /> After enabling it you will be prompted for your Gmail username and password.  Then you should see a sync icon in your status bar.  This lets you manually force a sync with google by clicking &#8220;sync now.&#8221; When it syncs you will probably have to resolve some &#8216;sync issues&#8217; (basically deciding which contact is correct, the Gmail or Address Book version.)<br />
<img src="http://blog.kunugiken.com/wp-content/uploads/2009/08/Screen-shot-2009-08-31-at-7.31.40-PM-copy.png" alt="Snow Leopard Sync Menu" title="Snow Leopard Sync Menu" width="302" height="133" class="alignnone size-full wp-image-243" /><br />
If this icon annoys you, just hold down the apple key and drag it out of the bar to remove it, to put it back you can enable it in iSync.app&#8217;s preferences.  </p>
<p>Now to tweak it.  Your computer syncs your contacts in a job in that runs through a process called launchd  (For those of you that don&#8217;t know, in Tiger and newer, launchd takes the job of cron on normal unix systems.)  By default this process runs only once every hour, we are going to try and tweak this.  To easily edit your loaded jobs, download Lingon from here <a href="http://sourceforge.net/projects/lingon/files/">http://sourceforge.net/projects/lingon/files/</a>.  Open up Lingon, on the left under &#8216;My Agents&#8217; you should see &#8216;com.google.GoogleContactSyncAgent.&#8217;  Click this, and you here you are able to change it from running every hour to as little time as every second (although I don&#8217;t recommend this AT ALL.)  Just adjust this setting to a shorter time period to speed it up.  The real trick here though is that you can set something called a watch file/directory.  This lets the process run when that file/directory has been modified.  To make the sync run whenever you change  one of your contacts you should just fill in under &#8220;Run when this file is modified&#8221; this file /Users/remi/Library/Application Support/AddressBook/AddressBook-v22.abcddb  This file is your address book database, so hence it runs when you update the database.  <img src="http://blog.kunugiken.com/wp-content/uploads/2009/08/Screen-shot-2009-08-31-at-7.29.44-PM.png" alt="Lingon Editing Snow Leopard Google Sync Agent" title="Lingon Editing Snow Leopard Google Sync Agent" width="580" height="521" class="alignnone size-full wp-image-242" />  Remember that this makes your contacts instantly updated from your computer to google, but no the other way around.  The frequency that the contacts come into your computer from google is determined by the &#8220;run it every&#8221; setting.  I do not know why apple did not have the file set to watch the address book database to begin with, so I&#8217;m not sure if there are any adverse effects, but there has been none that I have experienced so far.  Once you are finished editing the job, hit save, then log out and back in or restart for it to take effect.  To try it out just edit one of your contacts in Address Book.app and see the update automatically appear on Gmail, and if you iPhone is synced to Gmail, then right to your iPhone. </p>
<p>Please post a comment if you have problems with this method, good luck everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kunugiken.com/cocoa/snow-leopard-and-close-to-instant-gmail-contact-sync/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

