<?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>Giordano Scalzo&#039;s Personal Blog &#187; objective-c</title>
	<atom:link href="http://giordano.scalzo.biz/category/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://giordano.scalzo.biz</link>
	<description>Just another useless weblog</description>
	<lastBuildDate>Mon, 09 May 2011 09:50:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>iPhone Unit Test tips: Read a file in your test</title>
		<link>http://giordano.scalzo.biz/2011/04/18/iphone-unit-test-tips-read-a-file-in-your-test/</link>
		<comments>http://giordano.scalzo.biz/2011/04/18/iphone-unit-test-tips-read-a-file-in-your-test/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 10:44:27 +0000</pubDate>
		<dc:creator>giordano scalzo</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://giordano.scalzo.biz/?p=334</guid>
		<description><![CDATA[Very often I need to unit test something read from a file, but it seems very difficult to accomplish this simple task in iOS, so usually I give up. But today I felt was a good day to find a solution In my code I want to read a JSon data from a file, so [...]]]></description>
			<content:encoded><![CDATA[<p>Very often I need to unit test something read from a file, but it seems very difficult to accomplish this simple task in iOS, so usually I give up.<br />
But today I felt was a good day to find a solution <img src='http://giordano.scalzo.biz/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
In my code I want to read a JSon data from a file, so I wrote a simple test:</p>
<pre class="brush: cpp">
describe(@"Conference", ^{
    it(@"loads given a filename", ^{
        Conference *conference = [[Conference alloc]initWithFile:@"talks_with_three_tracks"];
        [[theValue([conference hasData]) should] beTrue];
    });
});
</pre>
<p>with a simple init method:</p>
<pre class="brush: cpp">
-(id)initWithFile:(NSString *)filename{
    if ((self = [super init])) {
        NSString* path = [[NSBundle mainBundle] pathForResource:filename ofType:@"json"];
        NSError *error;
        NSString* talksString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&#038;error];
        talks = [talksString JSONValue];
    }
    return self;
}

-(BOOL)hasData{
    return talks!=nil;
}
</pre>
<p>Unfortunately it doesn&#8217;t work <img src='http://giordano.scalzo.biz/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> , because path is nil;<br />
But here it isthe solution:<br />
instead of using <code>[NSBundle mainBundle]</code>, we should use the bundle associated with our class:</p>
<pre class="brush: cpp">
        NSString *path = [[NSBundle bundleForClass:[Conference class]] pathForResource:filename ofType:@"json"];
</pre>
<p>Simple and neat: thank you <a href="http://stackoverflow.com/questions/3067015/ocunit-nsbundle">StackOverflow</a> <img src='http://giordano.scalzo.biz/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/bdd' rel='tag' target='_self'>bdd</a>, <a class='technorati-link' href='http://technorati.com/tag/iphone' rel='tag' target='_self'>iphone</a>, <a class='technorati-link' href='http://technorati.com/tag/tdd' rel='tag' target='_self'>tdd</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://giordano.scalzo.biz/2011/04/18/iphone-unit-test-tips-read-a-file-in-your-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simplified Ad Hoc Distribution in Xcode 3.2</title>
		<link>http://giordano.scalzo.biz/2010/07/09/simplified-ad-hoc-distribution-in-xcode-3-2/</link>
		<comments>http://giordano.scalzo.biz/2010/07/09/simplified-ad-hoc-distribution-in-xcode-3-2/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 09:41:02 +0000</pubDate>
		<dc:creator>giordano scalzo</dc:creator>
				<category><![CDATA[objective-c]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://giordano.scalzo.biz/?p=311</guid>
		<description><![CDATA[Currently, Ad Hoc distribution is the only way to share an application to try itin to several devices or users (to maximum of 100 devices). Despite the Apple&#8217;s reputation to create simple and effective things, the Ad Hoc Distribution is one of awkward and cumbersome process I&#8217;ve ever seen: I admit every time I need [...]]]></description>
			<content:encoded><![CDATA[<p>Currently, Ad Hoc distribution is the only way to share an application to try itin to several devices or users (to maximum of 100 devices).<br />
Despite the Apple&#8217;s reputation to create simple and effective things, the Ad Hoc Distribution is one of awkward and cumbersome process I&#8217;ve ever seen: I admit every time I need to change a certificate to add or remove certain devices or I&#8217;ve to check another application, I hold my breath and start cold sweat until the end of process&#8230; but, in Xcode 3.2 they simplified it a little bit.</p>
<p>In Build menu you can find a new entry, <em><strong>Build and Archive</strong></em>, that creates your application and archive it, allowing to share and signing it in a more confortable way:<br />
<a href="http://giordano.scalzo.biz/wp-content/uploads/2010/07/MenuXcode.png"><img src="http://giordano.scalzo.biz/wp-content/uploads/2010/07/MenuXcode-300x288.png" alt="" title="MenuXcode" width="300" height="288" class="aligncenter size-medium wp-image-312" /></a></p>
<p>All archived applications are in a new window of the Organizer:<br />
<a href="http://giordano.scalzo.biz/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-11.27.07-AM.png"><img src="http://giordano.scalzo.biz/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-11.27.07-AM-300x201.png" alt="" title="Organizer" width="300" height="201" class="aligncenter size-medium wp-image-313" /></a></p>
<p>When you &#8220;share&#8221; an application an <em>ipa</em> file is created and you can share it with your betatesters:<br />
<a href="http://giordano.scalzo.biz/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-11.32.21-AM.png"><img src="http://giordano.scalzo.biz/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-11.32.21-AM-300x167.png" alt="" title="List of Ipa" width="300" height="167" class="aligncenter size-medium wp-image-314" /></a></p>
<p>Just a little thing, but it&#8217;s useful to manage all versions.</p>
<p>More information can be found in this <a href="http://iphonedevelopment.blogspot.com/2010/05/xcode-32-build-and-archive.html">interesting post</a> by <a href="http://iphonedevelopment.blogspot.com">Jeff LaMarche</a>: if are serious about iPhone development you must subscribe his <a href="http://iphonedevelopment.blogspot.com">blog</a> (and buy his book too <img src='http://giordano.scalzo.biz/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )</p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/apple' rel='tag' target='_self'>apple</a>, <a class='technorati-link' href='http://technorati.com/tag/iphone' rel='tag' target='_self'>iphone</a>, <a class='technorati-link' href='http://technorati.com/tag/xcode' rel='tag' target='_self'>xcode</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://giordano.scalzo.biz/2010/07/09/simplified-ad-hoc-distribution-in-xcode-3-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Agile iPhone Development&#8221; at Xpug Milano</title>
		<link>http://giordano.scalzo.biz/2010/04/02/agile-iphone-development-at-xpug-milano/</link>
		<comments>http://giordano.scalzo.biz/2010/04/02/agile-iphone-development-at-xpug-milano/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 07:29:54 +0000</pubDate>
		<dc:creator>giordano scalzo</dc:creator>
				<category><![CDATA[me]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[presentation]]></category>

		<guid isPermaLink="false">http://giordano.scalzo.biz/?p=303</guid>
		<description><![CDATA[Spring is almost arriving and it&#8217;s time for another Xpug Milano meeting in coding dojo format. This month we practiced with ObjectiveC; I gave an introductory presentation about the language, the ide and the framework, then we faced up to a nice Kata I proposed, inspired by some work of Brett Schuchert: the KataRpnCalculator. I [...]]]></description>
			<content:encoded><![CDATA[<p>Spring is almost arriving and it&#8217;s time for another Xpug Milano meeting in coding dojo format.</p>
<p>This month we practiced with ObjectiveC; I gave an introductory presentation about the language, the ide and the framework, then we faced up to a nice Kata I proposed, inspired by <a href="http://blog.objectmentor.com/articles/2010/03/30/some-rough-draft-tdd-demonstration-videos">some work of Brett Schuchert</a>: the <a href="http://milano-xpug.pbworks.com/f/KataRpnCalculator.doc">KataRpnCalculator</a>.</p>
<p>I admit I&#8217;m amazingly surprised by how quick the Xpuggers learned the basic of the language and how good is the <a href="http://github.com/gscalzo/Code-Kata/tree/KataRpnCalculator/KataCalculator/">code they produced</a>: awesome!<br />
It&#8217;s the proof that it&#8217;s always a people problem not a technologic problem, and people with the right attitude can produce very good code, even though they don&#8217;t know very well the language.</p>
<div style="width:425px" id="__ss_3589479"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/giordano/agile-iphone-development" title="Agile Iphone Development">Agile Iphone Development</a></strong><object width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=agileiphonedevelopment-100329181146-phpapp01&#038;rel=0&#038;stripped_title=agile-iphone-development" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=agileiphonedevelopment-100329181146-phpapp01&#038;rel=0&#038;stripped_title=agile-iphone-development" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/giordano">giordano scalzo</a>.</div>
</div>

<!-- start wp-tags-to-technorati 1.02 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://giordano.scalzo.biz/2010/04/02/agile-iphone-development-at-xpug-milano/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AgileCamp 2010: richness of difference</title>
		<link>http://giordano.scalzo.biz/2010/03/17/agilecamp-2010-richness-of-differerence/</link>
		<comments>http://giordano.scalzo.biz/2010/03/17/agilecamp-2010-richness-of-differerence/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 13:59:01 +0000</pubDate>
		<dc:creator>giordano scalzo</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[me]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[barcamp]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://giordano.scalzo.biz/?p=288</guid>
		<description><![CDATA[Some weeks ago, I has been lucky enough to attend to AgileCamp 2010, an awesome Barcamp organized by Sketchin, a Swiss UX and Web agency. With my good fellows XpUg-gers Gabriele, Andrea and Indrit, we reached a lot of old and new friends, all of them caring about quality and &#8220;Things Got Right&#8221;. I came [...]]]></description>
			<content:encoded><![CDATA[<p>Some weeks ago, I has been lucky enough to attend to <a href="http://barcamp.org/AgileCamp">AgileCamp 2010</a>, an awesome <a href="http://barcamp.org/">Barcamp </a>organized by <a href="http://www.sketchin.ch/it/blog/sketchin/vorremo-parlarvi-dellagilecamp2010.html">Sketchin</a>, a Swiss UX and Web agency.<br />
With my good fellows <a href="http://milano-xpug.pbworks.com/">XpUg-gers</a> <a href="http://www.gabrielelana.it/">Gabriele</a>, <a href="http://blog.andreafrancia.it/">Andrea</a> and <a href="http://it.linkedin.com/in/indritselimi">Indrit</a>, we reached a lot of old and new friends, all of them caring about quality and &#8220;<em>Things Got Righ</em>t&#8221;.<br />
I came back really enriched, mainly because I met people with experiences and point of view different than mine.</p>
<p>It has been my first <a href="http://barcamp.org/">Barcamp</a>, so I though it was necessary to present something, and I decided to assemble a little introduction to Tdd coding for Iphone.</p>
<p>Here there is the video of my presentation:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="320" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=10062595&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="320" src="http://vimeo.com/moogaloop.swf?clip_id=10062595&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/10062595">AgileCamp &#8211; iPhone agile DEV (di Giordano Scalzo)</a> from <a href="http://vimeo.com/sketchin">Sketchin</a> on <a href="http://vimeo.com">Vimeo</a>.</p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/barcamp' rel='tag' target='_self'>barcamp</a>, <a class='technorati-link' href='http://technorati.com/tag/bdd' rel='tag' target='_self'>bdd</a>, <a class='technorati-link' href='http://technorati.com/tag/iphone' rel='tag' target='_self'>iphone</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://giordano.scalzo.biz/2010/03/17/agilecamp-2010-richness-of-differerence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C for busy Java Developers 1: Calling methods</title>
		<link>http://giordano.scalzo.biz/2010/01/19/objective-c-for-busy-java-developers-1-calling-methods/</link>
		<comments>http://giordano.scalzo.biz/2010/01/19/objective-c-for-busy-java-developers-1-calling-methods/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 13:34:43 +0000</pubDate>
		<dc:creator>giordano scalzo</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://giordano.scalzo.biz/?p=261</guid>
		<description><![CDATA[At last I got a wonderful MacBookPro, so I started to study Objective-C to develop some cool Iphone applications. Objective-C is a language derived from C, to which it adds some modern features as ObjectOriented or Smalltalk-style messaging. As far I&#8217;m a complete newbie, I&#8217;m trying to learn it recalling some well know patterns and [...]]]></description>
			<content:encoded><![CDATA[<p>At last I got a wonderful MacBookPro, so I started to study <a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a> to develop some cool Iphone applications.</p>
<p><a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a> is a language derived from C, to which it adds some modern features as ObjectOriented or Smalltalk-style messaging.</p>
<p>As far I&#8217;m a complete newbie, I&#8217;m trying to learn it recalling some well know patterns and scenarios as made in Java , following <a href="http://cocoadevcentral.com/d/learn_objectivec/">this good tutorial</a>.</p>
<p><a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a> has a little strange way to call method, that could be disorienting at first glance:</p>
<p><b>Java</b>:</p>
<pre class='brush:java'>
object.method;
object.methodWithInput(input);

output = object.methodWithOutput();
output = object.methodWithInputAndOutput(Object input);
</pre>
<p><b>Objective-C</b>:</p>
<pre class='brush:c'>
[object method];
[object methodWithInput:input];

output = [object methodWithOutput];
output = [object methodWithInputAndOutput:input];
</pre>
<p>Obviously, it&#8217;s possible to call methods of class, instead of instance:</p>
<p><b>Java</b>:</p>
<pre class='brush:java'>
Object oString = new String();
</pre>
<p><b>Objective-C</b>:</p>
<pre class='brush:c'>
id oString = [NSString string];
</pre>
<p>The
<pre>id</pre>
<p> refers any kind of object, so it&#8217;s little different from Java counterpart.<br />
Better code is:</p>
<p><b>Java</b>:</p>
<pre class='brush:java'>
String sString = new String();
</pre>
<p><b>Objective-C</b>:</p>
<pre class='brush:c'>
NSString* sString = [NSString string];
</pre>
<p>With this style, it&#8217;s a little cumbersome write nested calls:</p>
<p><b>Java</b>:</p>
<pre class='brush:java'>
calculator.add(numbers.split());
</pre>
<p><b>Objective-C</b>:</p>
<pre class='brush:c'>
[calculator add:[numbers split]];
</pre>
<p>This syntax disencourage the nesting of more than one method.</p>
<p>Some methods take multiple input arguments, Objective-C deals with that allowing split method names:</p>
<p><b>Java</b>:</p>
<pre class='brush:java'>
boolean writeToFile(String path, boolean useAuxiliaryFile)

boolean result = myData.writeToFile("/tmp/log.txt", false);
</pre>
<p><b>Objective-C</b>:</p>
<pre class='brush:c'>
-(BOOL)writeToFile:(NSString *)path withAuxFile:(BOOL)useAuxiliaryFile;

BOOL result = [myData writeToFile:@"/tmp/log.txt" withAuxFile:NO];
</pre>
<p>Objective-C has properties built in, in Java you need to implement getters and setters:</p>
<p><b>Java</b>:</p>
<pre class='brush:java'>
photo.setCaption("Day at the Beach");
output = photo.getCaption();
</pre>
<p><b>Objective-C</b>:</p>
<pre class='brush:c'>
photo.caption = @"Day at the Beach";
output = photo.caption;
</pre>
<p>A property should be marked
<pre>@property</pre>
<p> in declaration and
<pre>@synthesize</pre>
<p> in implementation.</p>
<p>To create an object, the function
<pre>alloc</pre>
<p> should be called and then an init method should be called:</p>
<p><b>Java</b>:</p>
<pre class='brush:java'>
object = new ComplexObject(1.0f);
</pre>
<p><b>Objective-C</b>:</p>
<pre class='brush:c'>
object = [[ComplexObject alloc] initWithFloat:1.0f];
</pre>
<p>When working in an environment without garbage collector, any object created with alloc should be released:</p>
<p><b>Objective-C</b>:</p>
<pre class='brush:c'>
[object release];
</pre>
<p>To complete this introductory post, take a look at this <a href='http://giordano.scalzo.biz/wp-content/uploads/2010/01/objectiveccheatsheet.pdf'>ObjectiveC CheatSheet</a>: it contains all the most used constructs needed to start to code for Mac.</p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/java' rel='tag' target='_self'>java</a>, <a class='technorati-link' href='http://technorati.com/tag/objective-c' rel='tag' target='_self'>objective-c</a>, <a class='technorati-link' href='http://technorati.com/tag/tutorial' rel='tag' target='_self'>tutorial</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://giordano.scalzo.biz/2010/01/19/objective-c-for-busy-java-developers-1-calling-methods/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

