<?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>haniblog &#187; Xcode</title>
	<atom:link href="http://haniblog.com/category/xcode/feed" rel="self" type="application/rss+xml" />
	<link>http://haniblog.com</link>
	<description>Flame Artist by day. Proud Dad by, uhm, the rest of the time. Lover of everything Apple. Hater of everything Microsoft.</description>
	<lastBuildDate>Thu, 08 Jul 2010 17:20:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>First app: Count Characters</title>
		<link>http://haniblog.com/xcode/first-app-count-characters?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=first-app-count-characters</link>
		<comments>http://haniblog.com/xcode/first-app-count-characters#comments</comments>
		<pubDate>Sat, 19 Sep 2009 15:44:33 +0000</pubDate>
		<dc:creator>Hani</dc:creator>
				<category><![CDATA[Xcode]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[ObjC]]></category>

		<guid isPermaLink="false">http://haniblog.com/?p=1098</guid>
		<description><![CDATA[For my first application in Xcode I decided to take on the Count Characters challenge in Aaron Hillegass's excellent book Cocoa Programming for Mac OSX.]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="/wp-content/uploads/Xcode/FirstApp.png" class="alignnone" width="640" height="220" /></p>
<p>So <strong>SimpleWord</strong> is a little bit advanced at this stage. I started with one of the first challenges in <a href="http://www.amazon.co.uk/Cocoa-Programming-Mac-OS-X/dp/0321503619/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1253372471&#038;sr=8-1" target="_blank">Cocoa Programming for Mac OSX</a>, a simple application that counts characters in a line.</p>
<p>The window should have a text field where the user enters a string of characters, a button which tells the application to count the characters and a label to display the result. I started with creating a new Xcode project called <strong>CountCharacters</strong> and in there I created a new class and called it <strong>AppController</strong>. In the header file <strong>AppController.h</strong> file I declared the following:</p>
<blockquote>
<p>@interface AppController : NSObject {</p>
<p>	IBOutlet NSTextField *input;<br />
	IBOutlet NSTextField *output;<br />
}</p>
<p>- (IBAction)countIt:(id)sender;</p>
<p>@end
</p></blockquote>
<p>The first line creates an instance of NSObject and declares two outlets: <strong>input</strong> and <strong>output</strong>. When the user clicks the button, it triggers an IBAction method called <strong>countIt</strong>. With that done, I created a simple UI in Interface Builder:</p>
<p style="text-align: center;"><img alt="" src="/wp-content/uploads/Xcode/CountChars.png" class="alignnone" width="560" height="243" /></p>
<p>Then it was time to make the connections in Interface Builder. I created a new Object in IB, called it <strong>AppController</strong> and assigned it the same class. I set the input and output outlets to the new object and set the action of the button to the <strong>clickIt:</strong> method.</p>
<p>Back in Xcode, here&#8217;s what I coded in the implementation file <strong>AppController.m</strong>:</p>
<blockquote><p>
#import &#8220;AppController.h&#8221;</p>
<p>@implementation AppController</p>
<p>// Set the output text label to ??? on first run<br />
- (void)awakeFromNib<br />
{<br />
	[output setStringValue:@"???"];<br />
}</p>
<p>- (IBAction)countIt:(id)sender<br />
{<br />
	NSString *string = [input stringValue];		// Get the value of input<br />
	NSInteger count = [string length];			// Get the length of string</p>
<p>	NSString *display = [NSString stringWithFormat:@"'%@' has %i characters.", string, count];</p>
<p>	[output setStringValue:display];</p>
<p>}
</p></blockquote>
<p>First, <strong>awakeFromNib</strong> changes the Label field in the window to ??? when the application first runs. The <strong>countIt</strong> method was simple to put together despite stumbling on some syntax. The string instance variable, or ivar, gets the value from the input field in the application and the count ivar returns the length. The display ivar is formatted with the resulting output. The last line changes the label in the window from ??? to the value of display. Here&#8217;s what it tooks like:</p>
<p style="text-align: center;"><img alt="" src="/wp-content/uploads/Xcode/CountCharsOutput.png" class="alignnone" width="560" height="243" /></p>
]]></content:encoded>
			<wfw:commentRss>http://haniblog.com/xcode/first-app-count-characters/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beginning with Xcode</title>
		<link>http://haniblog.com/mac/beginning-with-xcode?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=beginning-with-xcode</link>
		<comments>http://haniblog.com/mac/beginning-with-xcode#comments</comments>
		<pubDate>Thu, 17 Sep 2009 06:12:48 +0000</pubDate>
		<dc:creator>Hani</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Developement]]></category>
		<category><![CDATA[ObjC]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://haniblog.com/?p=1091</guid>
		<description><![CDATA[For the past few months, I've been dabbling with programming on the Mac but I haven't had the time to really dive in. I was trying to explain to someone how it worked and realised that I couldn't really articulate how. Therefore, this will be a series of posts on how I intend to build applications using Xcode.]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="/wp-content/uploads/Xcode/Xcode.png" class="floatleft" width="200" height="200" style="margin-left: 15px; margin-bottom: 45px;"/></p>
<p>For the past few months, I&#8217;ve been dabbling with programming on the Mac but I haven&#8217;t had the time to really dive in. I was trying to explain to someone how it worked and realised that I couldn&#8217;t really articulate how. Therefore, this will be a series of posts on how I intend to build applications using <a href="http://www.apple.com/macosx/developers/" target="_blank">Xcode</a>, Apple&#8217;s free development environment.</p>
<p>There are plenty of <a href="http://www.cocoalab.com/?q=becomeanxcoder" target="_blank">excellent guides</a> but I found that they all had one flaw: obsolescence. I would be following a guide until it reaches a point where the window, method or button isn&#8217;t there in my version of Xcode. And I come to a screeching halt. Lots of the guides have been written for previous versions of Xcode and haven&#8217;t been updated.</p>
<p>Again, I intend to document my journey through development on my Mac and iPhone. I&#8217;ll start with writing a simple word processor, <strong>SimpleWord</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://haniblog.com/mac/beginning-with-xcode/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
