<?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>Remi&#039;s Blog</title>
	<atom:link href="http://blog.kunugiken.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.kunugiken.com</link>
	<description>A blog about programming and more</description>
	<lastBuildDate>Wed, 11 Aug 2010 04:40:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>HowTo: Disappearing NSTable Buttons</title>
		<link>http://blog.kunugiken.com/?p=367</link>
		<comments>http://blog.kunugiken.com/?p=367#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="p3673"><td class="code" id="p367code3"><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="p3674"><td class="code" id="p367code4"><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://blog.kunugiken.com/?feed=rss2&amp;p=367</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remi&#8217;s Chat App</title>
		<link>http://blog.kunugiken.com/?p=350</link>
		<comments>http://blog.kunugiken.com/?p=350#comments</comments>
		<pubDate>Mon, 19 Jul 2010 06:46:59 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone]]></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="p3506"><td class="code" id="p350code6"><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://blog.kunugiken.com/?feed=rss2&amp;p=350</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ThoMoNetworking Framework</title>
		<link>http://blog.kunugiken.com/?p=339</link>
		<comments>http://blog.kunugiken.com/?p=339#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="p3398"><td class="code" id="p339code8"><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://blog.kunugiken.com/?feed=rss2&amp;p=339</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New From Kunugiken WikiTyper</title>
		<link>http://blog.kunugiken.com/?p=327</link>
		<comments>http://blog.kunugiken.com/?p=327#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://blog.kunugiken.com/?feed=rss2&amp;p=327</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cocoa: Making Properties KVO Compliant</title>
		<link>http://blog.kunugiken.com/?p=278</link>
		<comments>http://blog.kunugiken.com/?p=278#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="p27810"><td class="code" id="p278code10"><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://blog.kunugiken.com/?feed=rss2&amp;p=278</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fixing Old Printer Drivers to Work in Snow Leopard</title>
		<link>http://blog.kunugiken.com/?p=273</link>
		<comments>http://blog.kunugiken.com/?p=273#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://blog.kunugiken.com/?feed=rss2&amp;p=273</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Snow Leopard and Close to Instant Gmail Contact Sync</title>
		<link>http://blog.kunugiken.com/?p=236</link>
		<comments>http://blog.kunugiken.com/?p=236#comments</comments>
		<pubDate>Tue, 01 Sep 2009 03:14:04 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[iPhone]]></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://blog.kunugiken.com/?feed=rss2&amp;p=236</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XHTML Compliancy</title>
		<link>http://blog.kunugiken.com/?p=194</link>
		<comments>http://blog.kunugiken.com/?p=194#comments</comments>
		<pubDate>Thu, 13 Aug 2009 04:27:04 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Site News]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=194</guid>
		<description><![CDATA[Just recently, I&#8217;ve gotten into making pages XHTML 1.0 Transitional compliant. What this means is that the coding of the webpage is fit to a more strict standard then just plain HTML. Practically speaking this means that the webpage fits into the web standards and will close guarantee that your webpage will display correctly on [...]]]></description>
			<content:encoded><![CDATA[<p>Just recently, I&#8217;ve gotten into making pages XHTML 1.0 Transitional compliant.  What this means is that the coding of the webpage is fit to a more strict standard then just plain HTML.  Practically speaking this means that the webpage fits into the web standards and will close guarantee that your webpage will display correctly on current and future web-standard compliant browsers.  There are three types of XHTML, Transitional, Strict, and Frameset.  Transitional is most widely used form of XHTML, and Strict is a version that is even more, well,  strict.  Making pages XHTML 1.0 Strict compliant can be difficult, but making it Transitional compliant isn&#8217;t hard at all.  It is mainly a matter of cleaning up your existing HTML.  I will cover how to make your webpage XHTML 1.0 Transitional compliant, as I have done with my site. But, don&#8217;t take my word, try clicking the button on the right that says &#8220;W3C XHTML 1.0&#8243; and it will go to W3C&#8217;s (the organization that makes the web standard) xhtml/html validator.  This is an extremely helpful tool, because it highlights the errors in your webpage that make it not xhtml compliant.</p>
<p>The first thing you must do is specify a doctype, here it is for transitional</p>

<div class="wp_codebox"><table><tr id="p19419"><td class="code" id="p194code19"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span>
<span style="color: #00bbdd;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span></pre></td></tr></table></div>

<p>Next comes the hmtl tag, but what you have to do in it is define the XML name space and the language as english</p>

<div class="wp_codebox"><table><tr id="p19420"><td class="code" id="p194code20"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> <span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en:gb&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></td></tr></table></div>

<p>Now add the head tag, specify the page encoding, and add a title which is required in valid XHTML</p>

<div class="wp_codebox"><table><tr id="p19421"><td class="code" id="p194code21"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head</span> <span style="color: #000066;">profile</span>=<span style="color: #ff0000;">&quot;http://gmpg.org/xfn/11&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hello World!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>For the most part all of your XHTML Transitional pages should start that way.  The next thing to do is just to take care of some pretty simple formatting rules.  First off, <b>all of your tags must be in lowercase</b>, and this goes for your tag&#8217;s properties too, for example onClick is bad, it has to be onclick, and &lt;P&gt; has to be &lt;p&gt;.  Next all your tags have to be closed, if you&#8217;re use to using single &lt;p&gt;  tags, you&#8217;ll have to do them in the self-closing style: &lt;p /&gt;.  Script and style tags must contain a type, so like the following,</p>

<div class="wp_codebox"><table><tr id="p19422"><td class="code" id="p194code22"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;,</span> <span style="color: #339933;">&lt;</span>style type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/css&quot;</span><span style="color: #339933;">&gt;&lt;/</span>style<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Also JavaScript not in an external file has to be escaped properly from the XHTML interpreter like follows:</p>

<div class="wp_codebox"><table><tr id="p19423"><td class="code" id="p194code23"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">//&lt;![CDATA[</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Hello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//]]&gt;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Image tags also, have to be closed but also they have to include the alt attribute, even if its just blank.</p>

<div class="wp_codebox"><table><tr id="p19424"><td class="code" id="p194code24"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://kunugiken.com/DRF/refresh.png&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>Another interesting thing to note is that when you declare your page as XHTML, is can break some of your CSS if it is not done correctly, one example would be the left property, for example the following will work in most browsers, but will not work on XHTML pages</p>

<div class="wp_codebox"><table><tr id="p19425"><td class="code" id="p194code25"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">40</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div>

<p>In actuality the left, top, right or bottom properties take a numerical value with a unit of measurement, so it has to be the following</p>

<div class="wp_codebox"><table><tr id="p19426"><td class="code" id="p194code26"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div>

<p>Remember that this is also true if you&#8217;re setting the CSS from inside JavaScript.</p>
<p>I hope that you found this helpful, these are just some of the things that caught me up while converting my site to XHTML.  Although it wasn&#8217;t so hard to make my blog part of the site proper XHTML because wordpress does a nice job of making XHTML compliant code anyway. (Although I had to mess with some of the plugins to get them to do it right).  <a href="http://www.w3schools.com/Xhtml/">Check out W3School&#8217;s page on XHTML</a>, and try taking their quiz!  I hope you found XHTML at least interesting, and will consider converting your pages.  Good Luck Everyone.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kunugiken.com/?feed=rss2&amp;p=194</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending Growl Notifications from Ubuntu</title>
		<link>http://blog.kunugiken.com/?p=139</link>
		<comments>http://blog.kunugiken.com/?p=139#comments</comments>
		<pubDate>Mon, 29 Jun 2009 18:36:09 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=139</guid>
		<description><![CDATA[If you&#8217;re like me then you love being up to date on things happening on your network.  So when things were happening on my Ubuntu server I wanted to be alerted in some way.  I tried to use email but that was just impractical.  Then I came up with the idea to use growl.  If [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me then you love being up to date on things happening on your network.  So when things were happening on my Ubuntu server I wanted to be alerted in some way.  I tried to use email but that was just impractical.  Then I came up with the idea to use growl.  If you don&#8217;t know, Growl is a messaging system for OS X that many applications use to notify the user with pleasant on screen notifications.  I remembered that growl would accept on notifications received over the network so I went out to the internet to find a way to send these notifications from Ubuntu.  I found a wonderful utility for doing it using python, which is a scripting language that comes pre-installed on Ubuntu. The name is <a href="http://code.google.com/p/pygnotify/">pygNotify</a>.  This would have been all fine and well and I would have had handy growl alerts form my server, but as it turned out there was very little documentation out there as to how to get this setup, and the included instructions are overly-simplified.  Therefore, I am writing this.</p>
<p>On the Ubuntu computer open the terminal, found in Applications &gt; Accessories &gt; Terminal.  First we&#8217;re going to create a folder to keep this growl stuff in.<br />
<code><br />
mkdir ~/growl<br />
cd ~/growl<br />
</code><br />
of course you don&#8217;t have to keep it in your home directory<br />
Next, lets download pygNotify<br />
<code><br />
wget http://pygnotify.googlecode.com/files/pygNotify-0.1.tgz<br />
tar xvfz pygNotify-0.1.tgz<br />
mv pygNotify-0.1/pygNotify.py .<br />
rm -r pygNotify-0.1<br />
</code><br />
The next thing you need is get the python libraries from the growl SDK, that you can download from their website here <a href="http://growl.info/source.php">http://growl.info/source.php</a> Unfortunately the SDK is in a dmg so you&#8217;ll have to use a mac to extract it then copy it to the Ubuntu machine.  You&#8217;ll need the folder Bindings/Python and also the script Bindings/Network/netgrowl.py.  I will write the rest assuming you copied them into a folder called dmg in your home directory.  Now we need to install the libraries.  Cd into the directory you copied over from the dmg.<br />
<code><br />
cd ~/dmg/Python<br />
sudo python setup.py install<br />
</code><br />
Now you need to move the netgrowl.py also from the dmg to the growl folder we created earlier<br />
<code><br />
mv ~/dmg/netgrowl.py ~/growl<br />
</code><br />
Then we should be done with the stuff from the dmg so we can clean up<br />
<code><br />
rm -r ~/dmg<br />
</code><br />
It should be all installed at this point.  Now we need to enable receiving network notifications on the mac computers you want to receive the notifications from your ubuntu machine.</p>
<p>If you haven&#8217;t already, download and install growl from its website <a href="http://growl.info/">http://growl.info/</a> Once installed, go to System Preferences in the apple menu and click on Growl.  Then click the network tab, then check &#8220;Listen for incoming notifications&#8221; and also check &#8220;Allow remote application registration&#8221; and set a password.  Even if you don&#8217;t want a password, as far as I can tell you have to set one for it to work.  Next you&#8217;ll need your computer&#8217;s ip address.  Open Terminal.app found in /Applications/Utilities and type<br />
<code><br />
ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\  -f2<br />
</code><br />
The output should be your ip, write it down because we&#8217;ll use it in this next step.  Repeat for each mac.  Now back on your ubuntu machine we need to register your server as an application that can send notifications on your mac.<br />
<code><br />
cd ~/growl<br />
python pygNotify.py -n "Ubuntu Server" -p "password" -H your.macs.ip.address -r -m "register"<br />
</code><br />
Please note that the second command is one line.  Replace password with the password you set earlier, and replace the part after -H with your mac ip address.  You&#8217;ll have to do this for every mac you setup to receive network notifications.</p>
<p>Note that the option after -n is the title of the application as it will appear to growl, and you can register multiple times with your mac if you use different names.  By using different names for different sets of notifications it becomes possible to set customized settings for both on your mac.   ie you could register &#8220;System Monitor&#8221; and maybe &#8220;Email Server&#8221; and have them have different message styles on the mac</p>
<p>Once the command runs, it should be registered on the mac and show up in the application list.  A keychain confirmation may come up on the mac asking you if you want growlHelper to access the keychain.  You should hit always allow, so this notification doesn&#8217;t come up every time.</p>
<p><span style="color: #ff0000;">Note:</span> If when you run the command you get a &#8220;IndentationError: expected an indented block&#8221; when you try to run the script, my best guess is that its due to the formatting being messed up when you copied it to the server.  If you find yourself unable to fix this just copy and paste the file from here: <a href="http://the.taoofmac.com/space/Projects/netgrowl">http://the.taoofmac.com/space/Projects/netgrowl</a> and finally that worked for me.</p>
<p>Now to send a message<br />
<code><br />
python pygNotify.py -n "Ubuntu Server" -t "test message" -p "password" -H your.macs.ip.address -m "hello world"<br />
</code><br />
Again note that the command is one line.  The part after the -t option is the title of the alert, and the part after -m is the message.  Also note if you want the alert to be sticky, meaning it stays on the screen, you can use the -s option.</p>
<p>And that&#8217;s, it hopefully.  If you have problems with it registering or sending messages, be sure to check your firewall settings, to make sure growlHelper.app can access the internet, or that udp port 9887 is open I believe.  Also you can try deleting the password set by growl in the keychain, and resetting it in the System Preferences Growl pane again.  This can reset growl&#8217;s privileges to access the keychain, which may or may not be set to deny it access.  The whole setup can be a finicky system at times, so good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kunugiken.com/?feed=rss2&amp;p=139</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Ever Heard of Pizzicato Five?</title>
		<link>http://blog.kunugiken.com/?p=131</link>
		<comments>http://blog.kunugiken.com/?p=131#comments</comments>
		<pubDate>Fri, 10 Apr 2009 21:44:30 +0000</pubDate>
		<dc:creator>Remi</dc:creator>
				<category><![CDATA[Japan]]></category>

		<guid isPermaLink="false">http://blog.kunugiken.com/?p=131</guid>
		<description><![CDATA[Ever heard of this Japanese group?  I stumbled upon this video of theirs, and found it to be awesome.  To me the video looks like its sporting some 60&#8242;s theme, at least some time before 1996, when it was made.  Overall, the video surprised me because it was simple but yet different.  The Pizzicato Five [...]]]></description>
			<content:encoded><![CDATA[<p>Ever heard of this Japanese group?  I stumbled upon this video of theirs, and found it to be awesome.  To me the video looks like its sporting some 60&#8242;s theme, at least some time before 1996, when it was made.  Overall, the video surprised me because it was simple but yet different.  The Pizzicato Five have been in surprising amount of things, all the way from Austin Powers to a Microsoft presentation at E3!.  Be sure to check out their <a href="http://en.wikipedia.org/wiki/Pizzicato_Five">wikipedia page</a>. Here&#8217;s the video, enjoy!</p>
<p><a href="http://blog.kunugiken.com/?p=131"><em>Click here to view the embedded video.</em></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kunugiken.com/?feed=rss2&amp;p=131</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
