<?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>Undolog.com &#187; Mobile</title>
	<atom:link href="http://www.undolog.com/category/mobile/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.undolog.com</link>
	<description>Research &#38; Development  Blog</description>
	<lastBuildDate>Thu, 18 Mar 2010 14:23:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>setAnimationDidStopSelector: usi diversi ed avanzati</title>
		<link>http://www.undolog.com/2010/03/08/setanimationdidstopselector-usi-diversi-ed-avanzati/</link>
		<comments>http://www.undolog.com/2010/03/08/setanimationdidstopselector-usi-diversi-ed-avanzati/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 20:42:06 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple iPhone]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[self]]></category>
		<category><![CDATA[setAnimationDelegate]]></category>
		<category><![CDATA[setAnimationDidStopSelector]]></category>
		<category><![CDATA[UIView]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2941</guid>
		<description><![CDATA[Nella maggioranza dei casi, o perchè siamo abituati o perchè l'abbiamo visto in tutorial e in alcuni testi, utilizziamo il setAnimationDidStopSelector in questa maniera:
PLAIN TEXT
Objective-C:




&#91;UIView beginAnimations:nil context:NULL&#93;;


&#91;UIView setAnimationDuration:1.5&#93;;


&#91;UIView setAnimationCurve:UIViewAnimationCurveEaseInOut&#93;;


&#91;UIView setAnimationDelegate:self&#93;;


&#91;UIView setAnimationDidStopSelector:@selector&#40;removeView&#41;&#93;;


&#160; &#160; 


myView.alpha = 0;


&#160; &#160; 


&#91;UIView commitAnimations&#93;;


&#160;


//


&#160;


- &#40;void&#41; removeView &#123;


&#160; &#160; &#91;myView removeFromSuperview&#93;;


&#125;






Nel codice sopra esposto la setAnimationDelegate imposta self come delegato e tramite [...]]]></description>
			<content:encoded><![CDATA[<p>Nella maggioranza dei casi, o perchè siamo abituati o perchè l'abbiamo visto in tutorial e in alcuni testi, utilizziamo il <code>setAnimationDidStopSelector</code> in questa maniera:</p>
<div class="igBar"><span id="lobjc-4"><a href="#" onclick="javascript:showCodeTxt('objc-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-4">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>1.5<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationCurve<span style="color: #002200;">:</span>UIViewAnimationCurveEaseInOut<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDelegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDidStopSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>removeView<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">myView.alpha <span style="color: #002200;">=</span> <span style="color: #2400d9;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> removeView <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>myView removeFromSuperview<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Nel codice sopra esposto la <code>setAnimationDelegate</code> imposta <code>self</code> come delegato e tramite la <code>setAnimationDidStopSelector</code> gli invia un messaggio <code>removeView</code> quando l'animazione è terminata. Il codice è di per sé corretto, tuttavia fa uso di una definizione di messaggio (<code>removeView</code>) che potrebbe essere omessa. Guardate adesso lo stesso codice, con il medesimo effetto, senza il messaggio <code>removeView</code>:</p>
<div class="igBar"><span id="lobjc-5"><a href="#" onclick="javascript:showCodeTxt('objc-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-5">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>1.5<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationCurve<span style="color: #002200;">:</span>UIViewAnimationCurveEaseInOut<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDelegate<span style="color: #002200;">:</span>myView<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDidStopSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>removeFromSuperview<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">myView.alpha <span style="color: #002200;">=</span> <span style="color: #2400d9;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
La cosa interessante di questo approccio è che <code>myView</code> potrebbe essere una sottoclasse di una <code>UIView</code>! Potrebbe quindi essere una nostra classe personalizzata con propri messaggi ed, nel modo esposto, tranquillamente richiamabile da <code>setAnimationDidStopSelector</code>. Inoltre, la <code>setAnimationDidStopSelector</code> accetta selettori con parametri:</p>
<div class="igBar"><span id="lobjc-6"><a href="#" onclick="javascript:showCodeTxt('objc-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-6">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>1.5<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationCurve<span style="color: #002200;">:</span>UIViewAnimationCurveEaseInOut<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDelegate<span style="color: #002200;">:</span>myView<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDidStopSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>myMessage<span style="color: #002200;">:</span>param1<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">myView.alpha <span style="color: #002200;">=</span> <span style="color: #2400d9;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Questo esempio può essere esteso a tutti qui casi dove impostiamo un delegato che, atro non è, che un puntatore ad un'istanza di un oggetto qualsiasi.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;bodytext=Nella%20maggioranza%20dei%20casi%2C%20o%20perch%C3%A8%20siamo%20abituati%20o%20perch%C3%A8%20l%27abbiamo%20visto%20in%20tutorial%20e%20in%20alcuni%20testi%2C%20utilizziamo%20il%20setAnimationDidStopSelector%20in%20questa%20maniera%3A%0D%0A%5Bobjc%5D%0D%0A%5BUIView%20beginAnimations%3Anil%20context%3ANULL%5D%3B%0D%0A%5BUIView%20setAnimationDurat" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;notes=Nella%20maggioranza%20dei%20casi%2C%20o%20perch%C3%A8%20siamo%20abituati%20o%20perch%C3%A8%20l%27abbiamo%20visto%20in%20tutorial%20e%20in%20alcuni%20testi%2C%20utilizziamo%20il%20setAnimationDidStopSelector%20in%20questa%20maniera%3A%0D%0A%5Bobjc%5D%0D%0A%5BUIView%20beginAnimations%3Anil%20context%3ANULL%5D%3B%0D%0A%5BUIView%20setAnimationDurat" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;t=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;annotation=Nella%20maggioranza%20dei%20casi%2C%20o%20perch%C3%A8%20siamo%20abituati%20o%20perch%C3%A8%20l%27abbiamo%20visto%20in%20tutorial%20e%20in%20alcuni%20testi%2C%20utilizziamo%20il%20setAnimationDidStopSelector%20in%20questa%20maniera%3A%0D%0A%5Bobjc%5D%0D%0A%5BUIView%20beginAnimations%3Anil%20context%3ANULL%5D%3B%0D%0A%5BUIView%20setAnimationDurat" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati%20-%20http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;story=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;body=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;link=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;headline=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Nella%20maggioranza%20dei%20casi%2C%20o%20perch%C3%A8%20siamo%20abituati%20o%20perch%C3%A8%20l%27abbiamo%20visto%20in%20tutorial%20e%20in%20alcuni%20testi%2C%20utilizziamo%20il%20setAnimationDidStopSelector%20in%20questa%20maniera%3A%0D%0A%5Bobjc%5D%0D%0A%5BUIView%20beginAnimations%3Anil%20context%3ANULL%5D%3B%0D%0A%5BUIView%20setAnimationDurat" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;t=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F&amp;title=setAnimationDidStopSelector%3A%20usi%20diversi%20ed%20avanzati" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F03%2F08%2Fsetanimationdidstopselector-usi-diversi-ed-avanzati%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple-iphone/" title="Apple iPhone" rel="tag">Apple iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/ipad/" title="iPad" rel="tag">iPad</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/selector/" title="selector" rel="tag">selector</a>, <a href="http://www.undolog.com/tag/self/" title="self" rel="tag">self</a>, <a href="http://www.undolog.com/tag/setanimationdelegate/" title="setAnimationDelegate" rel="tag">setAnimationDelegate</a>, <a href="http://www.undolog.com/tag/setanimationdidstopselector/" title="setAnimationDidStopSelector" rel="tag">setAnimationDidStopSelector</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/uiview/" title="UIView" rel="tag">UIView</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/29/iphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class/" title="iPhone: creare un metodo per rispondere agli eventi cross class (29 luglio, 2009)">iPhone: creare un metodo per rispondere agli eventi cross class</a> (0)</li>
	<li><a href="http://www.undolog.com/2010/02/10/come-creare-un-proprio-protocollo-con-delegato/" title="Come creare un proprio protocollo con delegato (10 febbraio, 2010)">Come creare un proprio protocollo con delegato</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/11/21/very-short-snippet-apple-iphone-file-system/" title="Very short snippet: Apple iPhone file system (21 novembre, 2009)">Very short snippet: Apple iPhone file system</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/12/14/objective-c-esporre-proprieta-in-una-classe/" title="Objective-C: esporre proprietà in una classe (14 dicembre, 2009)">Objective-C: esporre proprietà in una classe</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/13/iphone-secondapp-indovina-il-numero-parte-2/" title="iPhone SecondApp: indovina il numero &#8211; parte 2 (13 luglio, 2009)">iPhone SecondApp: indovina il numero &#8211; parte 2</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2010/03/08/setanimationdidstopselector-usi-diversi-ed-avanzati/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Come localizzare immagini e viste di Interface Builder</title>
		<link>http://www.undolog.com/2010/02/23/come-localizzare-immagini-e-viste-di-interface-builder/</link>
		<comments>http://www.undolog.com/2010/02/23/come-localizzare-immagini-e-viste-di-interface-builder/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 21:41:15 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[AppleSide]]></category>
		<category><![CDATA[Immagini]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[Localizzazione]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2918</guid>
		<description><![CDATA[Dopo aver illustrato come localizzare le nostre stringhe in Xcode, vediamo adesso quanto risulta semplice - applicando la medesima tecnica - localizzare immagini e viste/interfacce realizzate con Interface Builder.
Localizzare risorse grafiche
Il processo, come accennato, è il medesimo; se abbiamo un'immagine già inserita nelle nostre risorse, o ne inseriamo una nuova, e vogliamo "localizzarla" - cioè [...]]]></description>
			<content:encoded><![CDATA[<p>Dopo aver illustrato <strong><a href="http://www.appleside.it/develop/localizzare-le-applicazioni-apple-iphone-in-modo-rapido/" target="_blank">come localizzare le nostre stringhe in Xcode</a></strong>, vediamo adesso quanto risulta semplice - applicando la medesima tecnica - localizzare immagini e viste/interfacce realizzate con <strong>Interface Builder</strong>.</p>
<h4>Localizzare risorse grafiche</h4>
<p>Il processo, come accennato, è il medesimo; se abbiamo un'immagine già inserita nelle nostre risorse, o ne inseriamo una nuova, e vogliamo "localizzarla" - cioè gestire due o più immagini in base alle lingue supportate - basterà cliccare con il tasto destro sull'immagine (<code>Adium.png</code> in questo esempio) e selezionare <strong>Get Info</strong>:</p>
<p class="center"><img title="Get Info" src="http://www.undolog.com/wp-content/uploads/2010/02/Schermata-2010-02-23-a-17.16.17.png" alt="" width="470" height="673" /></p>
<p>Clicchiamo <strong>Make File Localizable</strong> in basso a sinistra.</p>
<p class="center"><img class="alignnone size-full wp-image-2923" title="Localizzable" src="http://www.undolog.com/wp-content/uploads/2010/02/Schermata-2010-02-23-a-17.43.54.png" alt="" width="470" height="673" /></p>
<p>Clicchiamo su <strong>Add Localization</strong> e inseriamo <code>Italian</code>:</p>
<p class="center"><img src="http://www.undolog.com/wp-content/uploads/2010/02/Schermata-2010-02-23-a-17.44.01.png" alt="" title="Schermata 2010-02-23 a 17.44.01" width="264" height="121" class="alignnone size-full wp-image-2924" /></p>
<p>In modo da ottenere:</p>
<p class="center"><img src="http://www.undolog.com/wp-content/uploads/2010/02/Schermata-2010-02-23-a-17.44.17.png" alt="" title="Schermata 2010-02-23 a 17.44.17" width="158" height="87" style="border:1px solid #aaa" /></p>
<p>La nostra immagine viene spostata (fisicamente, una delle rare volte in cui quello che accade nell'alberatura Xcode si riflette sul filesystem) sotto le cartelle virtuali <code>English.lproj</code> e <code>Italian.lproj</code> esattamente come accadeva con il testo:</p>
<p class="center"><img src="http://www.undolog.com/wp-content/uploads/2010/02/Schermata-2010-02-23-a-17.51.47.png" alt="" title="Schermata 2010-02-23 a 17.51.47" width="400" height="168" style="border:1px solid #aaa" /></p>
<p>A questo punto ognuna delle cartelle <code>English.lproj</code> e <code>Italian.lproj</code> contiene una stessa versione dell'immagine. Questa immagine è manipolabile all'interno di <strong>Interface Builder</strong>, dove ne vedremo - per default - la versione inglese.<br />
Arrivati a questo punto, basta sovrascrivere uno (o entrambi i file <code>Adium.png</code>) per ottenere una localizzazione delle immagini "lampo".</p>
<h4>Localizzare i file XIB</h4>
<p>Anche le interfacce costruite con <strong>Interface Builder</strong> possono essere localizzate nella loro interezza, quando lo si ritiene necessario. Il procedimento è identico a quello svolto con le risorse grafiche: aggiungiamo un <code>ViewController</code> (ad esempio <code>infoViewController</code>) con interfaccia <strong>XIB</strong>, lo selezioniamo, scegliamo <strong>Get Info</strong> dal menu contestuale, rendiamo il file localizzabile, aggiungiamo la localizzazione in italiano:</p>
<p class="center"><img src="http://www.undolog.com/wp-content/uploads/2010/02/Schermata-2010-02-23-a-22.30.29.png" alt="ViewController" title="ViewController" width="213" height="95" style="border:1px solid #aaa" /></p>
<p>Cliccando su <strong>English</strong> o su <strong>Italian</strong> si aprirà Interface Builder! Questa volta, sul filesystem, noteremo che sono state create due cartelle (<code>English.lproj</code> e <code>Italian.lproj</code>) all'interno della classica cartella <strong>Classes</strong>. Entrambe avranno il loro file <code>infoViewController.xib</code>. La comodità, in questo, risolta evidente nel codice; quando andremo ad istanziare il nostro controller si avrà un codice "pulito" di questo tipo:</p>
<div class="igBar"><span id="lobjc-8"><a href="#" onclick="javascript:showCodeTxt('objc-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-8">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">InfoViewController <span style="color: #002200;">*</span>info <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>InfoViewController alloc<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>info.view<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Come vedete non c'è traccia di nessuna dichiarazione relativa alla localizzazione, totalmente gestita da sistema. Le due interfacce, ovviamente, possono essere completamente differenti, in quanto risultano a tutti gli effetti come due file XIB separati.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;bodytext=Dopo%20aver%20illustrato%20come%20localizzare%20le%20nostre%20stringhe%20in%20Xcode%2C%20vediamo%20adesso%20quanto%20risulta%20semplice%20-%20applicando%20la%20medesima%20tecnica%20-%20localizzare%20immagini%20e%20viste%2Finterfacce%20realizzate%20con%20Interface%20Builder.%0D%0ALocalizzare%20risorse%20grafiche%0D%0AIl%20p" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;notes=Dopo%20aver%20illustrato%20come%20localizzare%20le%20nostre%20stringhe%20in%20Xcode%2C%20vediamo%20adesso%20quanto%20risulta%20semplice%20-%20applicando%20la%20medesima%20tecnica%20-%20localizzare%20immagini%20e%20viste%2Finterfacce%20realizzate%20con%20Interface%20Builder.%0D%0ALocalizzare%20risorse%20grafiche%0D%0AIl%20p" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;t=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;annotation=Dopo%20aver%20illustrato%20come%20localizzare%20le%20nostre%20stringhe%20in%20Xcode%2C%20vediamo%20adesso%20quanto%20risulta%20semplice%20-%20applicando%20la%20medesima%20tecnica%20-%20localizzare%20immagini%20e%20viste%2Finterfacce%20realizzate%20con%20Interface%20Builder.%0D%0ALocalizzare%20risorse%20grafiche%0D%0AIl%20p" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder%20-%20http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;story=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;body=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;link=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;headline=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Dopo%20aver%20illustrato%20come%20localizzare%20le%20nostre%20stringhe%20in%20Xcode%2C%20vediamo%20adesso%20quanto%20risulta%20semplice%20-%20applicando%20la%20medesima%20tecnica%20-%20localizzare%20immagini%20e%20viste%2Finterfacce%20realizzate%20con%20Interface%20Builder.%0D%0ALocalizzare%20risorse%20grafiche%0D%0AIl%20p" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;t=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F&amp;title=Come%20localizzare%20immagini%20e%20viste%20di%20Interface%20Builder" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F23%2Fcome-localizzare-immagini-e-viste-di-interface-builder%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/appleside/" title="AppleSide" rel="tag">AppleSide</a>, <a href="http://www.undolog.com/tag/immagini/" title="Immagini" rel="tag">Immagini</a>, <a href="http://www.undolog.com/tag/interface-builder/" title="Interface Builder" rel="tag">Interface Builder</a>, <a href="http://www.undolog.com/category/sviluppo/ipad/" title="iPad" rel="tag">iPad</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/tag/localizzazione/" title="Localizzazione" rel="tag">Localizzazione</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/tutorials/" title="Tutorials" rel="tag">Tutorials</a>, <a href="http://www.undolog.com/tag/xcode/" title="XCode" rel="tag">XCode</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/13/iphone-secondapp-indovina-il-numero-parte-2/" title="iPhone SecondApp: indovina il numero &#8211; parte 2 (13 luglio, 2009)">iPhone SecondApp: indovina il numero &#8211; parte 2</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/23/iphone-firstapp-indovina-il-numero-parte-1/" title="iPhone FirstApp: indovina il numero &#8211; parte 1 (23 giugno, 2009)">iPhone FirstApp: indovina il numero &#8211; parte 1</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/01/hi-phone/" title="Hi phone (1 giugno, 2009)">Hi phone</a> (7)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2010/02/23/come-localizzare-immagini-e-viste-di-interface-builder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Come creare un proprio protocollo con delegato</title>
		<link>http://www.undolog.com/2010/02/10/come-creare-un-proprio-protocollo-con-delegato/</link>
		<comments>http://www.undolog.com/2010/02/10/come-creare-un-proprio-protocollo-con-delegato/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 10:43:54 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[@protocol]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[eventi]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[Object]]></category>
		<category><![CDATA[property]]></category>
		<category><![CDATA[protocolli]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[self]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2896</guid>
		<description><![CDATA[Creare un proprio protocollo può essere utilissimo in una moltidudine di casi]]></description>
			<content:encoded><![CDATA[<p>Anche nei tutorial più semplici è possibile incontrare l'uso dei <strong>protocolli</strong>. Sarà certamente capitato a molti di utilizzare nel vostro view controller un <strong>protocollo</strong>, inserendo, accanto alla definzione dell'interfaccia, una dicitura simile a:</p>
<div class="igBar"><span id="lobjc-9"><a href="#" onclick="javascript:showCodeTxt('objc-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-9">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@interface</span> myViewController <span style="color: #002200;">:</span> UIViewController &lt;UIWebViewDelegate&gt; <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">...</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
I protocolli (nell'esempio sopra <code><UIWebViewDelegate></code>) sono un particolare modo di <strong>Objective-C</strong> di far <strong>ereditare</strong> comportamenti di una classe in un'altra. Nell'esempio mostrato sopra il nostro view controller <em>probabilmente</em> gestisce un componente <code>UIWebView</code>. Volendo rispondere agli eventi di quest'ultimo ne incorpora il protocollo <code>UIWebViewDelegate</code>.<br />
Così, implementato il protocollo <code>UIWebViewDelegate</code> nel nostro view controller, possiamo inserire nel file .m di implementazione i metodi (messaggi) che saranno invocati dal componente <code>UIWebView</code>, come ad esempio:</p>
<div class="igBar"><span id="lobjc-10"><a href="#" onclick="javascript:showCodeTxt('objc-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-10">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>webViewDidFinishLoad<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWebView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>webView <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Caricamento pagina terminato</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
In altre parole il nostro view controller condivide l'interfaccia <code><UIWebViewDelegate></code>, cioè ne eredita "alcune" caratteristice.</p>
<h4>Scrivere un nostro protocollo</h4>
<p>Immaginiamo di avere due classi: <code>ClasseA</code> e <code>ClasseB</code>. La classe <code>ClasseA</code> istanzia al suo interno la <code>ClasseB</code> che, a sua volta, genera un messaggio quando accade un determinato evento. Vorremo quindi scrivere un delegato per la <code>ClasseB</code> tale che possa essere utilizzato da <code>ClasseA</code> per rispondere e intercettare gli "eventi" rilasciati da <code>ClasseB</code>.<br />
La prima cosa da fare è aggiungere la definizione del protocollo nella <code>ClasseB</code> insieme ad una property (nello standard Apple) <code>delegate</code>:</p>
<div class="igBar"><span id="lobjc-11"><a href="#" onclick="javascript:showCodeTxt('objc-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-11">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@protocol</span> ClasseBDelegate &lt;NSObject&gt;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">@optional</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>mioEvento<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@end</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@interface</span> ClasseB <span style="color: #002200;">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// altre definizioni</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">id</span> &lt;ClasseBDelegate&gt; delegate;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>assign<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">id</span> &lt;ClasseBDelegate&gt; delegate;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Come da prassi, nel file .m della <code>ClasseB</code> inserire:</p>
<div class="igBar"><span id="lobjc-12"><a href="#" onclick="javascript:showCodeTxt('objc-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-12">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@synthesize</span> delegate;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Nel file di implementazione della classe <code>ClasseB</code> possiamo inserire il "fire" del nostro evento in questo modo:</p>
<div class="igBar"><span id="lobjc-13"><a href="#" onclick="javascript:showCodeTxt('objc-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-13">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self.delegate <span style="color: #002200;">!=</span> <span style="color: #a61390;">NULL</span> <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#91;</span>self.delegate respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>mioEvento<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>delegate mioEvento<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Prima di tutto verifichiamo che sia stato impostato un <strong>delegato</strong>: <code>self.delegate != NULL</code> e che questo delegato fornisca, o possa rispondere, al messaggio <code>mioEvento</code>: <code>[self.delegate respondsToSelector:@selector(mioEvento:)]</code>. Se entrambi le condizioni sono verificate allora viene invocato <code>mioEvento</code>; in questo esempio questo evento prevede anche un parametro (<code>id</code>) che è il puntatore all'istanza della classe <code>ClassB</code>.<br />
La classe <code>ClassA</code> non dovrà far altro che implementare il <strong>delegato</strong> e inserire il metodo <code>mioEvento</code>:</p>
<div class="igBar"><span id="lobjc-14"><a href="#" onclick="javascript:showCodeTxt('objc-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-14">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &quot;ClasseB.h&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@interface</span> ClasseA <span style="color: #002200;">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> &lt;ClasseBDelegate&gt; <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">...</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>mioEvento<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Nel file di implementazione quando creiamo la <code>ClassB</code> useremo:</p>
<div class="igBar"><span id="lobjc-15"><a href="#" onclick="javascript:showCodeTxt('objc-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-15">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">ClasseB <span style="color: #002200;">*</span>classeB <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>ClasseB alloc<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>classeB setDelegate<span style="color: #002200;">:</span> self<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Poi, inseriremo:</p>
<div class="igBar"><span id="lobjc-16"><a href="#" onclick="javascript:showCodeTxt('objc-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-16">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>mioEvento<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;mioEvento&quot;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;bodytext=Creare%20un%20proprio%20protocollo%20pu%C3%B2%20essere%20utilissimo%20in%20una%20moltidudine%20di%20casi" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;notes=Creare%20un%20proprio%20protocollo%20pu%C3%B2%20essere%20utilissimo%20in%20una%20moltidudine%20di%20casi" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;t=Come%20creare%20un%20proprio%20protocollo%20con%20delegato" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;annotation=Creare%20un%20proprio%20protocollo%20pu%C3%B2%20essere%20utilissimo%20in%20una%20moltidudine%20di%20casi" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Come%20creare%20un%20proprio%20protocollo%20con%20delegato%20-%20http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;story=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;body=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;link=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;headline=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Creare%20un%20proprio%20protocollo%20pu%C3%B2%20essere%20utilissimo%20in%20una%20moltidudine%20di%20casi" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;t=Come%20creare%20un%20proprio%20protocollo%20con%20delegato" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F&amp;title=Come%20creare%20un%20proprio%20protocollo%20con%20delegato" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F10%2Fcome-creare-un-proprio-protocollo-con-delegato%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/protocol/" title="@protocol" rel="tag">@protocol</a>, <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/class/" title="class" rel="tag">class</a>, <a href="http://www.undolog.com/tag/eventi/" title="eventi" rel="tag">eventi</a>, <a href="http://www.undolog.com/category/featured/" title="Featured" rel="tag">Featured</a>, <a href="http://www.undolog.com/category/sviluppo/ipad/" title="iPad" rel="tag">iPad</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/tag/message/" title="message" rel="tag">message</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/object/" title="Object" rel="tag">Object</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/property/" title="property" rel="tag">property</a>, <a href="http://www.undolog.com/tag/protocolli/" title="protocolli" rel="tag">protocolli</a>, <a href="http://www.undolog.com/tag/selector/" title="selector" rel="tag">selector</a>, <a href="http://www.undolog.com/tag/self/" title="self" rel="tag">self</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/29/iphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class/" title="iPhone: creare un metodo per rispondere agli eventi cross class (29 luglio, 2009)">iPhone: creare un metodo per rispondere agli eventi cross class</a> (0)</li>
	<li><a href="http://www.undolog.com/2010/03/08/setanimationdidstopselector-usi-diversi-ed-avanzati/" title="setAnimationDidStopSelector: usi diversi ed avanzati (8 marzo, 2010)">setAnimationDidStopSelector: usi diversi ed avanzati</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/10/29/objective-c-nslog-su-struct-c/" title="Objective-C: NSLog() su struct C (29 ottobre, 2009)">Objective-C: NSLog() su struct C</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2010/02/10/come-creare-un-proprio-protocollo-con-delegato/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Very short snippet: ottenere l&#8217;output di un URL in Objective-C</title>
		<link>http://www.undolog.com/2010/02/05/very-short-snippet-ottenere-loutput-di-un-url-in-objective-c/</link>
		<comments>http://www.undolog.com/2010/02/05/very-short-snippet-ottenere-loutput-di-un-url-in-objective-c/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 00:23:41 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Snipp]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[stringWithContentsOfURL]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2879</guid>
		<description><![CDATA[Avrei forse dovuto scrivere "Very very very, short snippet", tuttavia è un ottimo e comodissimo "trucchetto" questo che sto per mostrare. Eseguendo le "due" righe di codice indicate qui sotto, è possibile ottenere l'output di qualsiasi URL e manipolarlo.
PLAIN TEXT
Objective-C:




NSString *url = &#91;NSString stringWithFormat:@&#34;http://www.appleside.it/&#34;&#93;;


NSString *result = &#91;NSString stringWithContentsOfURL:&#91;NSURL URLWithString:url&#93;


&#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Avrei forse dovuto scrivere "Very very very, short snippet", tuttavia è un ottimo e comodissimo "trucchetto" questo che sto per mostrare. Eseguendo le "due" righe di codice indicate qui sotto, è possibile ottenere l'output di qualsiasi URL e manipolarlo.</p>
<div class="igBar"><span id="lobjc-19"><a href="#" onclick="javascript:showCodeTxt('objc-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-19">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>url <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.appleside.it/&quot;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>result <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithContentsOfURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> URLWithString<span style="color: #002200;">:</span>url<span style="color: #002200;">&#93;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encoding<span style="color: #002200;">:</span>NSASCIIStringEncoding </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Read from : %@ = &quot;</span>,apiEndpoint, result<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Ad esempio potremmo sfruttare molti servizi <strong>API REST</strong> per risolvere svariate problematiche. Tanto per fare un esempio pratico, immaginiamo di volre "comprimere"(trim) l'url http://www.undolog.com, come fanno molti servizi come <strong>Twitter</strong>, <strong>FriendFeed</strong> o <strong>Facebook</strong>. Ebbene potremmo sfruttare questo semplice codice:</p>
<div class="igBar"><span id="lobjc-20"><a href="#" onclick="javascript:showCodeTxt('objc-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-20">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>url <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.undolog.com&quot;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>apiRest <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://api.tr.im/v1/trim_simple?url=%@&quot;</span>,url<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>result <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithContentsOfURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> URLWithString<span style="color: #002200;">:</span>apiEndpoint<span style="color: #002200;">&#93;</span> </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encoding<span style="color: #002200;">:</span>NSASCIIStringEncoding </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;URL Originale: %@ - URL Compresso: %@&quot;</span>,url, result<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Tutto il merito, ovviamente, è del metodo <strong><code>stringWithContentsOfURL</code></strong>: in quanto permette di caricare in una stringa il contenuto (output) di un URL.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;bodytext=Avrei%20forse%20dovuto%20scrivere%20%22Very%20very%20very%2C%20short%20snippet%22%2C%20tuttavia%20%C3%A8%20un%20ottimo%20e%20comodissimo%20%22trucchetto%22%20questo%20che%20sto%20per%20mostrare.%20Eseguendo%20le%20%22due%22%20righe%20di%20codice%20indicate%20qui%20sotto%2C%20%C3%A8%20possibile%20ottenere%20l%27output%20di%20qualsiasi%20URL%20e%20manipo" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;notes=Avrei%20forse%20dovuto%20scrivere%20%22Very%20very%20very%2C%20short%20snippet%22%2C%20tuttavia%20%C3%A8%20un%20ottimo%20e%20comodissimo%20%22trucchetto%22%20questo%20che%20sto%20per%20mostrare.%20Eseguendo%20le%20%22due%22%20righe%20di%20codice%20indicate%20qui%20sotto%2C%20%C3%A8%20possibile%20ottenere%20l%27output%20di%20qualsiasi%20URL%20e%20manipo" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;t=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;annotation=Avrei%20forse%20dovuto%20scrivere%20%22Very%20very%20very%2C%20short%20snippet%22%2C%20tuttavia%20%C3%A8%20un%20ottimo%20e%20comodissimo%20%22trucchetto%22%20questo%20che%20sto%20per%20mostrare.%20Eseguendo%20le%20%22due%22%20righe%20di%20codice%20indicate%20qui%20sotto%2C%20%C3%A8%20possibile%20ottenere%20l%27output%20di%20qualsiasi%20URL%20e%20manipo" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C%20-%20http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;story=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;body=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;link=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;headline=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Avrei%20forse%20dovuto%20scrivere%20%22Very%20very%20very%2C%20short%20snippet%22%2C%20tuttavia%20%C3%A8%20un%20ottimo%20e%20comodissimo%20%22trucchetto%22%20questo%20che%20sto%20per%20mostrare.%20Eseguendo%20le%20%22due%22%20righe%20di%20codice%20indicate%20qui%20sotto%2C%20%C3%A8%20possibile%20ottenere%20l%27output%20di%20qualsiasi%20URL%20e%20manipo" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;t=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F&amp;title=Very%20short%20snippet%3A%20ottenere%20l%27output%20di%20un%20URL%20in%20Objective-C" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F02%2F05%2Fvery-short-snippet-ottenere-loutput-di-un-url-in-objective-c%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/api/" title="api" rel="tag">api</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/nsstring/" title="NSString" rel="tag">NSString</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/rest/" title="REST" rel="tag">REST</a>, <a href="http://www.undolog.com/tag/snipp/" title="Snipp" rel="tag">Snipp</a>, <a href="http://www.undolog.com/tag/snippets/" title="Snippets" rel="tag">Snippets</a>, <a href="http://www.undolog.com/tag/stringwithcontentsofurl/" title="stringWithContentsOfURL" rel="tag">stringWithContentsOfURL</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/10/09/very-short-snippet-iphone-numeri-casuali/" title="Very short snippet: iPhone, numeri casuali (9 ottobre, 2009)">Very short snippet: iPhone, numeri casuali</a> (0)</li>
	<li><a href="http://www.undolog.com/2008/11/19/very-short-snippet-wordpress-separare-le-categorie-in-due-colonne/" title="Very short snippet: Wordpress, separare le categorie in due colonne (19 novembre, 2008)">Very short snippet: Wordpress, separare le categorie in due colonne</a> (1)</li>
	<li><a href="http://www.undolog.com/2009/09/07/very-short-snippet-wordpress-migliorare-il-campo-cerca/" title="Very short snippet: Wordpress, migliorare il campo cerca (7 settembre, 2009)">Very short snippet: Wordpress, migliorare il campo cerca</a> (3)</li>
	<li><a href="http://www.undolog.com/2008/11/03/very-short-snippet-wordpress-administrator/" title="Very short snippet: Wordpress administrator? (3 novembre, 2008)">Very short snippet: Wordpress administrator?</a> (1)</li>
	<li><a href="http://www.undolog.com/2008/10/31/very-short-snippet-php-plain-date/" title="Very short snippet: PHP plain date (31 ottobre, 2008)">Very short snippet: PHP plain date</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2010/02/05/very-short-snippet-ottenere-loutput-di-un-url-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 utili snippet per Apple iPhone</title>
		<link>http://www.undolog.com/2010/01/08/10-utili-snippet-per-apple-iphone/</link>
		<comments>http://www.undolog.com/2010/01/08/10-utili-snippet-per-apple-iphone/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 22:53:28 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2739</guid>
		<description><![CDATA[Eseguire un metodo dopo n secondi
Tutta la famiglia performSelector è davvero interessante e può essere utile in una moltitudine di casi. La sua applicazione più semplice e comune è la seguente:
PLAIN TEXT
Objective-C:




&#91;self performSelector:@selector&#40;myMethod&#41; withObject:nil afterDelay:3&#93;;


//


- &#40;void&#41;myMethod &#123;


&#160; &#160; NSLog&#40;@&#34;Hello World!&#34;&#41;;


&#125;






Tuttavia considerate che il "timer" non è preciso. Questa procedura, quindi, va usata quando non è [...]]]></description>
			<content:encoded><![CDATA[<h4>Eseguire un metodo dopo n secondi</h4>
<p>Tutta la famiglia <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/performSelector:withObject:afterDelay:"><code>performSelector</code></a> è davvero interessante e può essere utile in una moltitudine di casi. La sua applicazione più semplice e comune è la seguente:</p>
<div class="igBar"><span id="lobjc-31"><a href="#" onclick="javascript:showCodeTxt('objc-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-31">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>self performSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>myMethod<span style="color: #002200;">&#41;</span> withObject<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> afterDelay<span style="color: #002200;">:</span>3<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>myMethod <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hello World!&quot;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Tuttavia considerate che il "timer" non è preciso. Questa procedura, quindi, va usata quando non è richiesta una "notevole" precisione temporale.</p>
<h4>Recuperare la versione dell'applicazione</h4>
<div class="igBar"><span id="lobjc-32"><a href="#" onclick="javascript:showCodeTxt('objc-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-32">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>version <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span> infoDictionary<span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBundleVersion&quot;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;versione = %@&quot;</span>, version<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>YES, <span style="text-transform:lowercase">true</span> o TRUE?</h4>
<p>Andando a spulciare nel Kernel Apple iPhone è possibile renderci conto che <code>YES</code>, <code>true</code> e <code>TRUE</code> sono in pratica la stessa edentica cosa:</p>
<div class="igBar"><span id="lobjc-33"><a href="#" onclick="javascript:showCodeTxt('objc-33'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-33">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// definizione di YES</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define YES (BOOL)1</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define NO &nbsp;(BOOL)0</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// definizione di true</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define true &nbsp;1</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define false 0</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// definizione di TRUE</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#if !defined(TRUE)</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #6e371a;">#define TRUE 1</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#endif</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#if !defined(FALSE)</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #6e371a;">#define FALSE 0</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#endif</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Almeno per adesso...</p>
<h4>Vibrazione</h4>
<div class="igBar"><span id="lobjc-34"><a href="#" onclick="javascript:showCodeTxt('objc-34'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-34">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &lt;AudioToolbox/AudioToolbox.h&gt;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">AudioServicesPlaySystemSound <span style="color: #002200;">&#40;</span>kSystemSoundID_Vibrate<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Puntatore CGImageRef a partire da un UIImage</h4>
<div class="igBar"><span id="lobjc-35"><a href="#" onclick="javascript:showCodeTxt('objc-35'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-35">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIImage <span style="color: #002200;">*</span>heart <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;LittleHeart.png&quot;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CGImageRef image <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>heart CGImage<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// L'immagine adesso può essere &quot;rasterizzata&quot; su un CGContextRef</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CGContextDrawImage<span style="color: #002200;">&#40;</span>c, <span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>0, 0, 100, 100<span style="color: #002200;">&#125;</span>, image<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Animazioni</h4>
<div class="igBar"><span id="lobjc-36"><a href="#" onclick="javascript:showCodeTxt('objc-36'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-36">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>1.5<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView setAnimationCurve<span style="color: #002200;">:</span>UIViewAnimationCurveEaseInOut<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>NSLog</h4>
<div class="igBar"><span id="lobjc-37"><a href="#" onclick="javascript:showCodeTxt('objc-37'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-37">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;NSString object %@ &quot;</span>, myString<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Float: %f &quot;</span>, myFloat<span style="color: #002200;">&#41;</span>; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Integer: %i &quot;</span>, myInt<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Convertitore da RGB a UIColor</h4>
<div class="igBar"><span id="lobjc-38"><a href="#" onclick="javascript:showCodeTxt('objc-38'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-38">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Passare parametri ad un NSTimer</h4>
<p>Sfruttando il parametro <code>userInfo</code> è possibile inviare un puntatore ad un nostro oggetto al metodo richiamato da timer.</p>
<div class="igBar"><span id="lobjc-39"><a href="#" onclick="javascript:showCodeTxt('objc-39'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-39">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/"><span style="color: #400080;">NSTimer</span></a> scheduledTimerWithTimeInterval<span style="color: #002200;">:</span>1 target<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>timerMethod<span style="color: #002200;">&#41;</span> userInfo<span style="color: #002200;">:</span>objectPointer repeats<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>timerMethod<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/"><span style="color: #400080;">NSTimer</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>timer <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Recupero il puntatore al mio oggetto</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">objectPointer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>timer userInfo<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// oppure</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>timer userInfo<span style="color: #002200;">&#93;</span> myMethod<span style="color: #002200;">&#93;</span>; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">int</span> a <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>timer userInfo<span style="color: #002200;">&#93;</span> myProperty<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// che è lo stesso</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">int</span> a <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>objectPointer myProperty<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Tempo di esecuzione</h4>
<p>Ecco un semplice modo per calcolare tempi brevi utili per verificare la velocità di esecuzione del codice:</p>
<div class="igBar"><span id="lobjc-40"><a href="#" onclick="javascript:showCodeTxt('objc-40'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-40">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CFAbsoluteTime initialTime <span style="color: #002200;">=</span> CFAbsoluteTimeGetCurrent<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ... code</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CFAbsoluteTime finalTime <span style="color: #002200;">=</span> CFAbsoluteTimeGetCurrent<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Tempo trascorso %f&quot;</span>, finalTime<span style="color: #002200;">-</span>initialTime<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;title=10%20utili%20snippet%20per%20Apple%20iPhone&amp;bodytext=Eseguire%20un%20metodo%20dopo%20n%20secondi%0D%0ATutta%20la%20famiglia%20performSelector%20%C3%A8%20davvero%20interessante%20e%20pu%C3%B2%20essere%20utile%20in%20una%20moltitudine%20di%20casi.%20La%20sua%20applicazione%20pi%C3%B9%20semplice%20e%20comune%20%C3%A8%20la%20seguente%3A%0D%0A%5Bobjc%5D%0D%0A%5Bself%20performSelector%3A%40selector%28myMethod%29" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;title=10%20utili%20snippet%20per%20Apple%20iPhone&amp;notes=Eseguire%20un%20metodo%20dopo%20n%20secondi%0D%0ATutta%20la%20famiglia%20performSelector%20%C3%A8%20davvero%20interessante%20e%20pu%C3%B2%20essere%20utile%20in%20una%20moltitudine%20di%20casi.%20La%20sua%20applicazione%20pi%C3%B9%20semplice%20e%20comune%20%C3%A8%20la%20seguente%3A%0D%0A%5Bobjc%5D%0D%0A%5Bself%20performSelector%3A%40selector%28myMethod%29" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;t=10%20utili%20snippet%20per%20Apple%20iPhone" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;title=10%20utili%20snippet%20per%20Apple%20iPhone&amp;annotation=Eseguire%20un%20metodo%20dopo%20n%20secondi%0D%0ATutta%20la%20famiglia%20performSelector%20%C3%A8%20davvero%20interessante%20e%20pu%C3%B2%20essere%20utile%20in%20una%20moltitudine%20di%20casi.%20La%20sua%20applicazione%20pi%C3%B9%20semplice%20e%20comune%20%C3%A8%20la%20seguente%3A%0D%0A%5Bobjc%5D%0D%0A%5Bself%20performSelector%3A%40selector%28myMethod%29" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=10%20utili%20snippet%20per%20Apple%20iPhone%20-%20http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=10%20utili%20snippet%20per%20Apple%20iPhone&amp;story=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;title=10%20utili%20snippet%20per%20Apple%20iPhone" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=10%20utili%20snippet%20per%20Apple%20iPhone&amp;body=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=10%20utili%20snippet%20per%20Apple%20iPhone&amp;link=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;headline=10%20utili%20snippet%20per%20Apple%20iPhone&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;title=10%20utili%20snippet%20per%20Apple%20iPhone&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Eseguire%20un%20metodo%20dopo%20n%20secondi%0D%0ATutta%20la%20famiglia%20performSelector%20%C3%A8%20davvero%20interessante%20e%20pu%C3%B2%20essere%20utile%20in%20una%20moltitudine%20di%20casi.%20La%20sua%20applicazione%20pi%C3%B9%20semplice%20e%20comune%20%C3%A8%20la%20seguente%3A%0D%0A%5Bobjc%5D%0D%0A%5Bself%20performSelector%3A%40selector%28myMethod%29" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;title=10%20utili%20snippet%20per%20Apple%20iPhone" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;t=10%20utili%20snippet%20per%20Apple%20iPhone" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=10%20utili%20snippet%20per%20Apple%20iPhone&amp;url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;title=10%20utili%20snippet%20per%20Apple%20iPhone" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F&amp;title=10%20utili%20snippet%20per%20Apple%20iPhone" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2010%2F01%2F08%2F10-utili-snippet-per-apple-iphone%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/snippets/" title="Snippets" rel="tag">Snippets</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/10/09/very-short-snippet-iphone-numeri-casuali/" title="Very short snippet: iPhone, numeri casuali (9 ottobre, 2009)">Very short snippet: iPhone, numeri casuali</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/20/xcode-consigli-sul-debugging-preferences/" title="XCode: consigli sul Debugging Preferences (20 luglio, 2009)">XCode: consigli sul Debugging Preferences</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/16/very-short-trick-fermare-nstimer/" title="Very short trick: fermare NSTimer (16 giugno, 2009)">Very short trick: fermare NSTimer</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2010/01/08/10-utili-snippet-per-apple-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C: esporre proprietà in una classe</title>
		<link>http://www.undolog.com/2009/12/14/objective-c-esporre-proprieta-in-una-classe/</link>
		<comments>http://www.undolog.com/2009/12/14/objective-c-esporre-proprieta-in-una-classe/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 16:30:11 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[@synthesize]]></category>
		<category><![CDATA[Apple iPhone]]></category>
		<category><![CDATA[classe]]></category>
		<category><![CDATA[getter]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[property]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[retain]]></category>
		<category><![CDATA[setter]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2773</guid>
		<description><![CDATA[Vorrei mostrare e discutere alcuni esempi sul come aggiungere e manipolare proprietà in una Classe Objective-C. Un esempio classico, per l'appunto, è il seguente; nella definizione della nostra interfaccia di classe definiamo due proprietà nome e cognome:
PLAIN TEXT
Objective-C:




// MyClass.h


#import &#60;Foundation/Foundation.h&#62;


&#160;


@interface MyClass : NSObject &#123;


&#160; &#160; NSString *nome;


&#160; &#160; NSString *cognome;


&#125;


&#160;


@property &#40;retain&#41; NSString *nome;


@property &#40;retain&#41; NSString [...]]]></description>
			<content:encoded><![CDATA[<p>Vorrei mostrare e discutere alcuni esempi sul come aggiungere e manipolare proprietà in una Classe Objective-C. Un esempio classico, per l'appunto, è il seguente; nella definizione della nostra interfaccia di classe definiamo due proprietà <code>nome</code> e <code>cognome</code>:</p>
<div class="igBar"><span id="lobjc-51"><a href="#" onclick="javascript:showCodeTxt('objc-51'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-51">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// MyClass.h</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@interface</span> MyClass <span style="color: #002200;">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>nome;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>cognome;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>nome;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>retain<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>cognome;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@end</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nel file di implementazione inseriamo la dichiarazione <code>@synthesize</code> in modo tale che Xcode produca per noi i metodi <code>getter</code> e <code>setter</code> usati rispettivamente per leggere ed impostare le nostre due proprietà:</p>
<div class="igBar"><span id="lobjc-52"><a href="#" onclick="javascript:showCodeTxt('objc-52'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-52">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// MyClass.m</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &quot;MyClass.h&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@implementation</span> MyClass</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@synthesize</span> nome, cognome;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@end</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Quando andremo ad utilizzare la nostra classe <code>MyClass</code>, cioè quando istanziaremo un oggetto di tipo <code>MyClass</code>, possiamo scrive:</p>
<div class="igBar"><span id="lobjc-53"><a href="#" onclick="javascript:showCodeTxt('objc-53'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-53">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// qualsiasi altra classe, come AppDelegate</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// nel file .h</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &quot;MyClass.h&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@class</span> TestViewController;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@interface</span> TesAppDelegate <span style="color: #002200;">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> &lt;UIApplicationDelegate&gt; <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; UIWindow <span style="color: #002200;">*</span>window;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; TestViewController <span style="color: #002200;">*</span>viewController;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; MyClass <span style="color: #002200;">*</span>miaClasse;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// nel file .m</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">miaClasse <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>MyClass alloc<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">miaClasse.nome <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Giovambattista&quot;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;miaClasse.nome = %@&quot;</span>, miaClasse.nome<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Oppure, che è equivalente:</p>
<div class="igBar"><span id="lobjc-54"><a href="#" onclick="javascript:showCodeTxt('objc-54'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-54">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// sempre nel file .m</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>miaClasse setNome<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Undolog&quot;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;miaClasse.nome = %@&quot;</span>,<span style="color: #002200;">&#91;</span>miaClasse nome<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Fin qui tutto bene. Tuttavia potrebbe fuorviare l'equivalenza delle "variabli" interne (ivar) con il nome della proprietà vera e propria. Per capire la differenza, ripropongo lo stesso esempio facendo a meno, questa volta, di <code>@synthesize</code>. Ora, quindi, dovremmo occuparci noi di scrivere i metodi <code>getter</code> e <code>setter</code>. Per sottolineare ulteriormente le differenze, rinominerò le variabili interne inserendo un underscore davanti al nome. Ma vediamo il codice:</p>
<div class="igBar"><span id="lobjc-55"><a href="#" onclick="javascript:showCodeTxt('objc-55'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-55">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@interface</span> MyClass <span style="color: #002200;">:</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>_nome;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>_cognome;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> nome; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// get</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> cognome; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">// get</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setNome<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>stringaIngresso; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// set</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setCognome<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>stringaIngresso; &nbsp;<span style="color: #11740a; font-style: italic;">// set</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@end</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
A differenza dell'esempio precedente i puntatori alla variabili interne (incapsultate) sono diventati <code>_nome</code> e <code>_cognome</code>. Inoltre troviamo quattro definizioni di metodi che rappresentano le nostre <code>get</code> e <code>set</code>. <code>@property</code> è scomparso, in quanto non serve più.<br />
Vediamo il file di implementazione <code>MyClass.m</code>:</p>
<div class="igBar"><span id="lobjc-56"><a href="#" onclick="javascript:showCodeTxt('objc-56'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-56">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &quot;MyClass.h&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@implementation</span> MyClass</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// get per &quot;nome&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> nome <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">return</span> _nome;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// set per &quot;nome&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setNome<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>stringaIngresso <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; _nome <span style="color: #002200;">=</span> stringaIngresso;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// get per &quot;cognome&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> cognome <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">return</span> _cognome;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// set per &quot;cognome&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setCognome<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>stringaIngresso <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; _cognome <span style="color: #002200;">=</span> stringaIngresso;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@end</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Una classe così scritta potrà essere utilizzata esattamente come la precedente, cioè:</p>
<div class="igBar"><span id="lobjc-57"><a href="#" onclick="javascript:showCodeTxt('objc-57'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-57">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">miaClasse <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>MyClass alloc<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">miaClasse.nome <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Giovambattista&quot;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;miaClasse.nome = %@&quot;</span>, miaClasse.nome<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Oppure, che è equivalente:</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>miaClasse setNome<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Undolog&quot;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;miaClasse.nome = %@&quot;</span>,<span style="color: #002200;">&#91;</span>miaClasse nome<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
A livello didattico l'abbandono di <code>@synthesize</code> ci ha costretto a scrivere "da soli" i metodi di <code>get</code> e <code>set</code>, evidenziando - anche con l'aggiunta dell'underscore - le differenze tra il nome della proprietà e la sua ivar interna <code>_nome</code>.<br />
A livello funzionale l'uso dei metodi personali <code>get</code> e <code>set</code> permette un reale controllo del dato prima della sua impostazione (o prima della sua lettura) e quindi un reale incapsulamento per proteggere la variabile interna.<br />
Ad esempio sarebbe possibile impedire il passaggio di stringhe vuote alla proprietà <code>nome</code>:</p>
<div class="igBar"><span id="lobjc-58"><a href="#" onclick="javascript:showCodeTxt('objc-58'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-58">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setNome<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>stringaIngresso <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> stringaIngresso <span style="color: #002200;">==</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span> <span style="color: #002200;">&#41;</span> stringaIngresso <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;senza nome&quot;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; _nome <span style="color: #002200;">=</span> stringaIngresso;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Ulteriore variante</h4>
<p>Se desiderate utilizzare le variabili interne con l'underscore davanti (chi rpoviene da Adobe Actionscript potrebbe essere abituato così) non è necessario abbandonare l'uso della direttiva <code>@synthesize</code>. Xcode permette infatti di "fondere" i metodi sopra indicati:</p>
<div class="igBar"><span id="lobjc-59"><a href="#" onclick="javascript:showCodeTxt('objc-59'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-59">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@synthesize</span> nome <span style="color: #002200;">=</span> _nome;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@synthesize</span> cognome <span style="color: #002200;">=</span> _cognome;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Così facendo potremmo usare internamente il puntatore a <code>_nome</code>, "sintetizzato" - verso l'esterno - come proprietà <code>nome</code>. Inoltre, se è vero che l'uso di <code>@synthesize</code> produce la generazione automatica dei metodi (messaggi) di <code>getter</code> e <code>setter</code>, è vero anche che lo fa solo se non li trova, quindi se desiderate "implementare" un vostro metodo di <code>getter</code> e/o <code>setter</code> <strong>potete farlo anche se avete usato la direttiva <code>@synthesize</code></strong>.</p>
<h4>Allocazioni di memoria</h4>
<p>Negli esempi di sopra ho omesso alcuni dettagli importanti ai fini di una reale implementazione. Prima di tutto non ho illustrato nessun metodo <code>init()</code>, utile ai fini dell'inizializzazione dell'oggetto e dei sui valori di default. Inoltre, manca l'aggiunta di un metodo <code>dealloc()</code>:</p>
<div class="igBar"><span id="lobjc-60"><a href="#" onclick="javascript:showCodeTxt('objc-60'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-60">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// file MyClass.m</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &quot;MyClass.h&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@implementation</span> MyClass</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> init <span style="color: #002200;">&#123;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super init<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span> </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; _nome <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Nome preimpostato&quot;</span>; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; _cognome <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cognome preimpostato&quot;</span>; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#125;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">return</span> self; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> dealloc <span style="color: #002200;">&#123;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_nome release<span style="color: #002200;">&#93;</span>; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_cognome release<span style="color: #002200;">&#93;</span>; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>super dealloc<span style="color: #002200;">&#93;</span>; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> nome <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">return</span> _nome;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setNome<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>stringaIngresso <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> stringaIngresso <span style="color: #002200;">==</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span> <span style="color: #002200;">&#41;</span> stringaIngresso <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;senza nome&quot;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; _nome <span style="color: #002200;">=</span> stringaIngresso;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> cognome <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">return</span> _cognome;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setCognome<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>stringaIngresso <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; _cognome <span style="color: #002200;">=</span> stringaIngresso;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@end</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
In futuro vedremo poi i dettagli sulle proprietà <code>readonly</code>, <code>retain</code>, etc... <img src='http://www.undolog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;bodytext=Vorrei%20mostrare%20e%20discutere%20alcuni%20esempi%20sul%20come%20aggiungere%20e%20manipolare%20propriet%C3%A0%20in%20una%20Classe%20Objective-C.%20Un%20esempio%20classico%2C%20per%20l%27appunto%2C%20%C3%A8%20il%20seguente%3B%20nella%20definizione%20della%20nostra%20interfaccia%20di%20classe%20definiamo%20due%20propriet%C3%A0%20nome%20e%20" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;notes=Vorrei%20mostrare%20e%20discutere%20alcuni%20esempi%20sul%20come%20aggiungere%20e%20manipolare%20propriet%C3%A0%20in%20una%20Classe%20Objective-C.%20Un%20esempio%20classico%2C%20per%20l%27appunto%2C%20%C3%A8%20il%20seguente%3B%20nella%20definizione%20della%20nostra%20interfaccia%20di%20classe%20definiamo%20due%20propriet%C3%A0%20nome%20e%20" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;t=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;annotation=Vorrei%20mostrare%20e%20discutere%20alcuni%20esempi%20sul%20come%20aggiungere%20e%20manipolare%20propriet%C3%A0%20in%20una%20Classe%20Objective-C.%20Un%20esempio%20classico%2C%20per%20l%27appunto%2C%20%C3%A8%20il%20seguente%3B%20nella%20definizione%20della%20nostra%20interfaccia%20di%20classe%20definiamo%20due%20propriet%C3%A0%20nome%20e%20" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;headline=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Vorrei%20mostrare%20e%20discutere%20alcuni%20esempi%20sul%20come%20aggiungere%20e%20manipolare%20propriet%C3%A0%20in%20una%20Classe%20Objective-C.%20Un%20esempio%20classico%2C%20per%20l%27appunto%2C%20%C3%A8%20il%20seguente%3B%20nella%20definizione%20della%20nostra%20interfaccia%20di%20classe%20definiamo%20due%20propriet%C3%A0%20nome%20e%20" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;t=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F&amp;title=Objective-C%3A%20esporre%20propriet%C3%A0%20in%20una%20classe" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F14%2Fobjective-c-esporre-proprieta-in-una-classe%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/synthesize/" title="@synthesize" rel="tag">@synthesize</a>, <a href="http://www.undolog.com/tag/apple-iphone/" title="Apple iPhone" rel="tag">Apple iPhone</a>, <a href="http://www.undolog.com/tag/classe/" title="classe" rel="tag">classe</a>, <a href="http://www.undolog.com/tag/getter/" title="getter" rel="tag">getter</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/object-oriented/" title="Object-Oriented" rel="tag">Object-Oriented</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/property/" title="property" rel="tag">property</a>, <a href="http://www.undolog.com/tag/release/" title="Release" rel="tag">Release</a>, <a href="http://www.undolog.com/tag/retain/" title="retain" rel="tag">retain</a>, <a href="http://www.undolog.com/tag/setter/" title="setter" rel="tag">setter</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2007/11/09/aggiungere-propriet-ad-un-movieclip/" title="Aggiungere propriet&agrave; ad un MovieClip (9 novembre, 2007)">Aggiungere propriet&agrave; ad un MovieClip</a> (3)</li>
	<li><a href="http://www.undolog.com/2009/11/21/very-short-snippet-apple-iphone-file-system/" title="Very short snippet: Apple iPhone file system (21 novembre, 2009)">Very short snippet: Apple iPhone file system</a> (0)</li>
	<li><a href="http://www.undolog.com/2010/03/08/setanimationdidstopselector-usi-diversi-ed-avanzati/" title="setAnimationDidStopSelector: usi diversi ed avanzati (8 marzo, 2010)">setAnimationDidStopSelector: usi diversi ed avanzati</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/12/da-actionscript-ad-objective-c/" title="Da Actionscript ad Objective-C (12 giugno, 2009)">Da Actionscript ad Objective-C</a> (1)</li>
	<li><a href="http://www.undolog.com/2009/06/26/come-eliminare-nslog-dai-sorgenti-xcode/" title="Come eliminare NSLog() dai sorgenti XCode (26 giugno, 2009)">Come eliminare NSLog() dai sorgenti XCode</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/12/14/objective-c-esporre-proprieta-in-una-classe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Browser o Mobile Browser?</title>
		<link>http://www.undolog.com/2009/12/11/browser-o-mobile-browser/</link>
		<comments>http://www.undolog.com/2009/12/11/browser-o-mobile-browser/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 00:30:28 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[$_SERVER['HTTP_USER_AGENT']]]></category>
		<category><![CDATA[Apple iPhone]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[Device]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Tema]]></category>
		<category><![CDATA[user-agent]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2764</guid>
		<description><![CDATA[Il nostro sito Web ormai non è visualizzato solo da postazioni PC. Con la diffusione del mobile, grazie soprattutto ad Apple iPhone, l'accesso al sito o blog viene sempre più spesso effettuato da dispositivi mobili di vario tipo. Diventa quindi esigenza di molti Web Developer saper intercettare ed identificare i diversi "agenti", cioè gli strumenti [...]]]></description>
			<content:encoded><![CDATA[<p>Il nostro sito Web ormai non è visualizzato solo da postazioni PC. Con la diffusione del mobile, grazie soprattutto ad Apple iPhone, l'accesso al sito o blog viene sempre più spesso effettuato da dispositivi mobili di vario tipo. Diventa quindi esigenza di molti Web Developer saper intercettare ed identificare i diversi "agenti", cioè gli strumenti con cui un utente visualizza (naviga) le nostre pagine.<br />
Per Wordpress, ad esempio, che rappresenta una delle piattaforme Blog più diffuse, esistono da tempo Plugin che permettono di visualizzare in modo differente il nostro Blog in base al "device" che si utilizza. Questi Plugin non fanno altro che intercettare il tipo di dispositivo usato e re-indirizzare un tema appropriato. Chi possiede un Apple iPhone avrà infatti notato che alcuni Blog vengono visualizzati in modo totalmente differente, proprio grazie al cambio del tema effettuato da questi Plugin.<br />
La procedura, tuttavia, può essere generalizzata e applicata a qualsiasi pagina Web. Sfruttando PHP è possibile identificare l'agente e decidere che tipo di output emettere:</p>
<div class="igBar"><span id="lphp-64"><a href="#" onclick="javascript:showCodeTxt('php-64'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-64">
<div class="php" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// fornisce le informazioni sull'agente che ha richiesto</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// questa pagina</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// l'output sarà tipo:</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; it; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">?&gt;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Analizzando la stringa contenuta in <code>$_SERVER['HTTP_USER_AGENT']</code> è possibile identificare l'agente e comportarsi di conseguenza. Se ad esempio avete la necessità di mostrare un contenuto con un layout differente agli utenti Apple iPhone, potete inserire queste righe di codice nella vostra pagina PHP:</p>
<div class="igBar"><span id="lphp-65"><a href="#" onclick="javascript:showCodeTxt('php-65'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-65">
<div class="php" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/eregi"><span style="color: #990000;">eregi</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'iphone'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Apple iPhone</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Tutti gli altri</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">?&gt;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Le combinazioni sono varie e, senza impazzire più di tanto, consiglio di scaricare questa piccola libreria (che poi non è nemmeno una libreria) scritta da <a target="_blank" href="http://detectmobilebrowsers.mobi/">Andy Moore</a>: <a target="_blank" href="http://detectmobilebrowsers.mobi/?dl">mobile_device_detect.php</a>.<br />
Il suo uso è davvero semplice e permette di intercettare moltissimi device: Apple iPhone/iPod, Android, Palm, ...<br />
Per utilizzarla basta includere il file <a target="_blank" href="http://detectmobilebrowsers.mobi/?dl">mobile_device_detect.php</a> e controllare il rotorno della funzione <code>mobile_device_detect()</code>:</p>
<div class="igBar"><span id="lphp-66"><a href="#" onclick="javascript:showCodeTxt('php-66'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-66">
<div class="php" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #b1b100;">require_once</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mobile_device_detect.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$mobile</span> <span style="color: #339933;">=</span> mobile_device_detect<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
La funzione accetta otto (8) parametri (opzionali) in ingresso che ne determinano il comportamento, compreso un re-direct nel caso sia stato trovato il device specificato nei parametri d'ingresso. Sul sito è disponibile anche un comodo <a target="_blank" href="http://detectmobilebrowsers.mobi/#generator">"generatore" di funzione</a> che chiarisce il funzionamento.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;title=Browser%20o%20Mobile%20Browser%3F&amp;bodytext=Il%20nostro%20sito%20Web%20ormai%20non%20%C3%A8%20visualizzato%20solo%20da%20postazioni%20PC.%20Con%20la%20diffusione%20del%20mobile%2C%20grazie%20soprattutto%20ad%20Apple%20iPhone%2C%20l%27accesso%20al%20sito%20o%20blog%20viene%20sempre%20pi%C3%B9%20spesso%20effettuato%20da%20dispositivi%20mobili%20di%20vario%20tipo.%20Diventa%20quindi%20esi" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;title=Browser%20o%20Mobile%20Browser%3F&amp;notes=Il%20nostro%20sito%20Web%20ormai%20non%20%C3%A8%20visualizzato%20solo%20da%20postazioni%20PC.%20Con%20la%20diffusione%20del%20mobile%2C%20grazie%20soprattutto%20ad%20Apple%20iPhone%2C%20l%27accesso%20al%20sito%20o%20blog%20viene%20sempre%20pi%C3%B9%20spesso%20effettuato%20da%20dispositivi%20mobili%20di%20vario%20tipo.%20Diventa%20quindi%20esi" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;t=Browser%20o%20Mobile%20Browser%3F" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;title=Browser%20o%20Mobile%20Browser%3F&amp;annotation=Il%20nostro%20sito%20Web%20ormai%20non%20%C3%A8%20visualizzato%20solo%20da%20postazioni%20PC.%20Con%20la%20diffusione%20del%20mobile%2C%20grazie%20soprattutto%20ad%20Apple%20iPhone%2C%20l%27accesso%20al%20sito%20o%20blog%20viene%20sempre%20pi%C3%B9%20spesso%20effettuato%20da%20dispositivi%20mobili%20di%20vario%20tipo.%20Diventa%20quindi%20esi" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Browser%20o%20Mobile%20Browser%3F%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Browser%20o%20Mobile%20Browser%3F&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;title=Browser%20o%20Mobile%20Browser%3F" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Browser%20o%20Mobile%20Browser%3F&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Browser%20o%20Mobile%20Browser%3F&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;headline=Browser%20o%20Mobile%20Browser%3F&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;title=Browser%20o%20Mobile%20Browser%3F&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Il%20nostro%20sito%20Web%20ormai%20non%20%C3%A8%20visualizzato%20solo%20da%20postazioni%20PC.%20Con%20la%20diffusione%20del%20mobile%2C%20grazie%20soprattutto%20ad%20Apple%20iPhone%2C%20l%27accesso%20al%20sito%20o%20blog%20viene%20sempre%20pi%C3%B9%20spesso%20effettuato%20da%20dispositivi%20mobili%20di%20vario%20tipo.%20Diventa%20quindi%20esi" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;title=Browser%20o%20Mobile%20Browser%3F" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;t=Browser%20o%20Mobile%20Browser%3F" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Browser%20o%20Mobile%20Browser%3F&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;title=Browser%20o%20Mobile%20Browser%3F" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F&amp;title=Browser%20o%20Mobile%20Browser%3F" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F11%2Fbrowser-o-mobile-browser%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/_serverhttp_user_agent/" title="$_SERVER[&#039;HTTP_USER_AGENT&#039;]" rel="tag">$_SERVER[&#039;HTTP_USER_AGENT&#039;]</a>, <a href="http://www.undolog.com/tag/apple-iphone/" title="Apple iPhone" rel="tag">Apple iPhone</a>, <a href="http://www.undolog.com/tag/browser/" title="browser" rel="tag">browser</a>, <a href="http://www.undolog.com/tag/device/" title="Device" rel="tag">Device</a>, <a href="http://www.undolog.com/category/sviluppo/internet/" title="Internet" rel="tag">Internet</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/tag/ipod/" title="iPod" rel="tag">iPod</a>, <a href="http://www.undolog.com/tag/layout/" title="Layout" rel="tag">Layout</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/category/sviluppo/internet/php/" title="PHP" rel="tag">PHP</a>, <a href="http://www.undolog.com/tag/php/" title="PHP" rel="tag">PHP</a>, <a href="http://www.undolog.com/tag/plugin/" title="Plugin" rel="tag">Plugin</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/tema/" title="Tema" rel="tag">Tema</a>, <a href="http://www.undolog.com/tag/user-agent/" title="user-agent" rel="tag">user-agent</a>, <a href="http://www.undolog.com/category/sviluppo/internet/wordpress/" title="WordPress" rel="tag">WordPress</a>, <a href="http://www.undolog.com/tag/wordpress/" title="WordPress" rel="tag">WordPress</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2008/10/03/wordpress-come-scrivere-un-reply-to-comment-usando-jquery/" title="Wordpress: come scrivere un reply to comment usando jQuery (3 ottobre, 2008)">Wordpress: come scrivere un reply to comment usando jQuery</a> (18)</li>
	<li><a href="http://www.undolog.com/2009/06/04/un-tema-wordpress-per-tutti/" title="Un tema Wordpress per tutti (4 giugno, 2009)">Un tema Wordpress per tutti</a> (20)</li>
	<li><a href="http://www.undolog.com/2010/03/03/wp-bannerize-2-4-1/" title="WP Bannerize 2.4.1 (3 marzo, 2010)">WP Bannerize 2.4.1</a> (0)</li>
	<li><a href="http://www.undolog.com/2008/10/27/wordpress-scrivere-un-logout-personale/" title="Wordpress: scrivere un logout personale (27 ottobre, 2008)">Wordpress: scrivere un logout personale</a> (2)</li>
	<li><a href="http://www.undolog.com/2008/11/01/wordpress-rimuovere-i-menu-dellamministrazione/" title="Wordpress: rimuovere i menu dell&#8217;amministrazione (1 novembre, 2008)">Wordpress: rimuovere i menu dell&#8217;amministrazione</a> (12)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/12/11/browser-o-mobile-browser/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Apple iPhone: creare un custom toggle button</title>
		<link>http://www.undolog.com/2009/12/04/apple-iphone-creare-un-custom-toggle-button/</link>
		<comments>http://www.undolog.com/2009/12/04/apple-iphone-creare-un-custom-toggle-button/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 11:00:05 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Apple iPhone]]></category>
		<category><![CDATA[buttonWithType]]></category>
		<category><![CDATA[CGRect]]></category>
		<category><![CDATA[Immagini]]></category>
		<category><![CDATA[initWithFrame]]></category>
		<category><![CDATA[UIButton]]></category>
		<category><![CDATA[UIControlStateHighlighted]]></category>
		<category><![CDATA[UIControlStateSelected]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2745</guid>
		<description><![CDATA[Gli stati UIControlStateSelected o UIControlStateHighlighted non funzionano quando un UIButton è impostato in modalità UIButtonTypeCustom! O meglio, non funzionano come dovrebbero (perchè riservati agli altri tipi di bottone), ad esempio per creare un bottone a due stati: toggle appunto. Se abbiamo creato due immagini (stato1.png e stato2.png) per il nostro bottone, possiamo procedere in questo [...]]]></description>
			<content:encoded><![CDATA[<p>Gli stati <code>UIControlStateSelected</code> o <code>UIControlStateHighlighted</code> non funzionano quando un <code>UIButton</code> è impostato in modalità <code>UIButtonTypeCustom</code>! O meglio, non funzionano come dovrebbero (perchè riservati agli altri tipi di bottone), ad esempio per creare un bottone a due stati: toggle appunto. Se abbiamo creato due immagini (stato1.png e stato2.png) per il nostro bottone, possiamo procedere in questo modo:</p>
<div class="igBar"><span id="lobjc-70"><a href="#" onclick="javascript:showCodeTxt('objc-70'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-70">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Nell'header file creiamo una variabile globale che usaremo per</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// controllare il toggle state</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">BOOL</span> toggleFlag;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ora creiamo il nostro bottone:</p>
<div class="igBar"><span id="lobjc-71"><a href="#" onclick="javascript:showCodeTxt('objc-71'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-71">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Creaiamo un bottone e lo poniamo inizialmente nello stato &quot;stato1.png&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Modificate initWithFrame:(CGRect){100,100,50,50} con la posizione e </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// dimensioni della vostra immmagine</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">toggleFlag <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIButton <span style="color: #002200;">*</span>toggleButton <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIButton buttonWithType<span style="color: #002200;">:</span>UIButtonTypeCustom<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>100,100,50,50<span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>toggleButton setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>toggleButton setBackgroundImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;stato1.png&quot;</span><span style="color: #002200;">&#93;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>toggleButton addTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>onToggle<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> forControlEvents<span style="color: #002200;">:</span>UIControlEventTouchUpInside<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>toggleButton<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Quando si clicca sul bottone verrà inviato un messaggio gestito da <code>onToggle</code>:</p>
<div class="igBar"><span id="lobjc-72"><a href="#" onclick="javascript:showCodeTxt('objc-72'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-72">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>onToggle<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Recupero puntatore al UIButton</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIButton <span style="color: #002200;">*</span>buttonClicked <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>UIButton <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sender;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Eseguo il toogle</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">toggleFlag <span style="color: #002200;">=</span> <span style="color: #002200;">!</span>toggleFlag;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>buttonClicked setBackgroundImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>toggleFlag<span style="color: #002200;">&#41;</span> ? <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;stato1.png&quot;</span> <span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;stato2.png&quot;</span><span style="color: #002200;">&#93;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;bodytext=Gli%20stati%20UIControlStateSelected%20o%20UIControlStateHighlighted%20non%20funzionano%20quando%20un%20UIButton%20%C3%A8%20impostato%20in%20modalit%C3%A0%20UIButtonTypeCustom%21%20O%20meglio%2C%20non%20funzionano%20come%20dovrebbero%20%28perch%C3%A8%20riservati%20agli%20altri%20tipi%20di%20bottone%29%2C%20ad%20esempio%20per%20crear" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;notes=Gli%20stati%20UIControlStateSelected%20o%20UIControlStateHighlighted%20non%20funzionano%20quando%20un%20UIButton%20%C3%A8%20impostato%20in%20modalit%C3%A0%20UIButtonTypeCustom%21%20O%20meglio%2C%20non%20funzionano%20come%20dovrebbero%20%28perch%C3%A8%20riservati%20agli%20altri%20tipi%20di%20bottone%29%2C%20ad%20esempio%20per%20crear" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;t=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;annotation=Gli%20stati%20UIControlStateSelected%20o%20UIControlStateHighlighted%20non%20funzionano%20quando%20un%20UIButton%20%C3%A8%20impostato%20in%20modalit%C3%A0%20UIButtonTypeCustom%21%20O%20meglio%2C%20non%20funzionano%20come%20dovrebbero%20%28perch%C3%A8%20riservati%20agli%20altri%20tipi%20di%20bottone%29%2C%20ad%20esempio%20per%20crear" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;headline=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Gli%20stati%20UIControlStateSelected%20o%20UIControlStateHighlighted%20non%20funzionano%20quando%20un%20UIButton%20%C3%A8%20impostato%20in%20modalit%C3%A0%20UIButtonTypeCustom%21%20O%20meglio%2C%20non%20funzionano%20come%20dovrebbero%20%28perch%C3%A8%20riservati%20agli%20altri%20tipi%20di%20bottone%29%2C%20ad%20esempio%20per%20crear" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;t=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F&amp;title=Apple%20iPhone%3A%20creare%20un%20custom%20toggle%20button" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F04%2Fapple-iphone-creare-un-custom-toggle-button%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/apple-iphone/" title="Apple iPhone" rel="tag">Apple iPhone</a>, <a href="http://www.undolog.com/tag/buttonwithtype/" title="buttonWithType" rel="tag">buttonWithType</a>, <a href="http://www.undolog.com/tag/cgrect/" title="CGRect" rel="tag">CGRect</a>, <a href="http://www.undolog.com/tag/immagini/" title="Immagini" rel="tag">Immagini</a>, <a href="http://www.undolog.com/tag/initwithframe/" title="initWithFrame" rel="tag">initWithFrame</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/uibutton/" title="UIButton" rel="tag">UIButton</a>, <a href="http://www.undolog.com/tag/uicontrolstatehighlighted/" title="UIControlStateHighlighted" rel="tag">UIControlStateHighlighted</a>, <a href="http://www.undolog.com/tag/uicontrolstateselected/" title="UIControlStateSelected" rel="tag">UIControlStateSelected</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/06/12/apple-iphone-sdk-30-risolto-baco-su-uibutton-buttonwithtype/" title="Apple iPhone SDK 3.0: risolto baco su UIButton buttonWithType (12 giugno, 2009)">Apple iPhone SDK 3.0: risolto baco su UIButton buttonWithType</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/11/apple-iphone-sdk-30-prime-incompatibilita/" title="Apple iPhone SDK 3.0: prime incompatibilità (11 giugno, 2009)">Apple iPhone SDK 3.0: prime incompatibilità</a> (1)</li>
	<li><a href="http://www.undolog.com/2009/12/01/very-short-snippet-streaming-mp3-file-su-apple-iphone/" title="Very short snippet: streaming mp3 file su Apple iPhone (1 dicembre, 2009)">Very short snippet: streaming mp3 file su Apple iPhone</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/27/objective-c-unalternativa-alluso-di-cgrectmake/" title="Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake (27 luglio, 2009)">Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake</a> (2)</li>
	<li><a href="http://www.undolog.com/2009/10/29/objective-c-nslog-su-struct-c/" title="Objective-C: NSLog() su struct C (29 ottobre, 2009)">Objective-C: NSLog() su struct C</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/12/04/apple-iphone-creare-un-custom-toggle-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Very short snippet: streaming mp3 file su Apple iPhone</title>
		<link>http://www.undolog.com/2009/12/01/very-short-snippet-streaming-mp3-file-su-apple-iphone/</link>
		<comments>http://www.undolog.com/2009/12/01/very-short-snippet-streaming-mp3-file-su-apple-iphone/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:12:47 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Apple iPhone]]></category>
		<category><![CDATA[AVAudioPlayer]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[NSData]]></category>
		<category><![CDATA[NSURLConnection]]></category>
		<category><![CDATA[NSURLRequest]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2722</guid>
		<description><![CDATA[Un'alternativa davvero semplice per eseguire uno streaming di un file mp3 su Apple iPhone potrebbe essere:
PLAIN TEXT
Objective-C:




// Utilizzare AVFoundation Framework e nell'header file (.h) aggiungere


// #import &#60;AVFoundation/AVFoundation.h&#62;


&#160;


// Nell'implementazione 


// inserite l'url del file mp3


NSString * soundFilePath = @&#34;http://www.server.com/test.mp3&#34;;


&#160;


NSURL * fileURL = &#91;NSURL URLWithString:soundFilePath&#93;;&#160; 


NSURLRequest * request = &#91;NSURLRequest requestWithURL:fileURL&#93;;


NSData *dataRaw = &#91;NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil&#93;;


&#160;


AVAudioPlayer [...]]]></description>
			<content:encoded><![CDATA[<p>Un'alternativa davvero semplice per eseguire uno <strong>streaming di un file mp3</strong> su Apple iPhone potrebbe essere:</p>
<div class="igBar"><span id="lobjc-76"><a href="#" onclick="javascript:showCodeTxt('objc-76'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-76">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Utilizzare AVFoundation Framework e nell'header file (.h) aggiungere</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// #import &lt;AVFoundation/AVFoundation.h&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Nell'implementazione </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// inserite l'url del file mp3</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span> soundFilePath <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.server.com/test.mp3&quot;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> <span style="color: #002200;">*</span> fileURL <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> URLWithString<span style="color: #002200;">:</span>soundFilePath<span style="color: #002200;">&#93;</span>;&nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"><span style="color: #400080;">NSURLRequest</span></a> <span style="color: #002200;">*</span> request <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"><span style="color: #400080;">NSURLRequest</span></a> requestWithURL<span style="color: #002200;">:</span>fileURL<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span style="color: #400080;">NSData</span></a> <span style="color: #002200;">*</span>dataRaw <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/"><span style="color: #400080;">NSURLConnection</span></a> sendSynchronousRequest<span style="color: #002200;">:</span>request returningResponse<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">AVAudioPlayer <span style="color: #002200;">*</span> audioPlayer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>AVAudioPlayer alloc<span style="color: #002200;">&#93;</span> initWithData<span style="color: #002200;">:</span>dataRaw error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>audioPlayer play<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Ora, non direttamente correlato a questo "snippet", guardate come è facile con la (tanto odiata) sintassi a parentesi quadre di Objective-c ridurre tutto ad una sola riga:</p>
<div class="igBar"><span id="lobjc-77"><a href="#" onclick="javascript:showCodeTxt('objc-77'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-77">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">AVAudioPlayer <span style="color: #002200;">*</span> audioPlayer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>AVAudioPlayer alloc<span style="color: #002200;">&#93;</span> initWithData<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/"><span style="color: #400080;">NSURLConnection</span></a> sendSynchronousRequest<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"><span style="color: #400080;">NSURLRequest</span></a> requestWithURL<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> URLWithString<span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.server.com/test.mp3&quot;</span> <span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#93;</span> returningResponse<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>audioPlayer play<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Indentando il codice un po' meglio si ha:</p>
<div class="igBar"><span id="lobjc-78"><a href="#" onclick="javascript:showCodeTxt('objc-78'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-78">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">AVAudioPlayer <span style="color: #002200;">*</span> audioPlayer <span style="color: #002200;">=</span> </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>AVAudioPlayer alloc<span style="color: #002200;">&#93;</span> </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; initWithData<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/"><span style="color: #400080;">NSURLConnection</span></a> </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendSynchronousRequest<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"><span style="color: #400080;">NSURLRequest</span></a> </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; requestWithURL<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> URLWithString<span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.server.com/test.mp3&quot;</span> <span style="color: #002200;">&#93;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#93;</span> </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returningResponse<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>audioPlayer play<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Questione di gusti, ovviamente...</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;bodytext=Un%27alternativa%20davvero%20semplice%20per%20eseguire%20uno%20streaming%20di%20un%20file%20mp3%20su%20Apple%20iPhone%20potrebbe%20essere%3A%0D%0A%5Bobjc%5D%0D%0A%2F%2F%20Utilizzare%20AVFoundation%20Framework%20e%20nell%27header%20file%20%28.h%29%20aggiungere%0D%0A%2F%2F%20%23import%20%0D%0A%0D%0A%2F%2F%20Nell%27implementazione%20%0D%0A%2F%2F%20inserite%20l%27url%20de" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;notes=Un%27alternativa%20davvero%20semplice%20per%20eseguire%20uno%20streaming%20di%20un%20file%20mp3%20su%20Apple%20iPhone%20potrebbe%20essere%3A%0D%0A%5Bobjc%5D%0D%0A%2F%2F%20Utilizzare%20AVFoundation%20Framework%20e%20nell%27header%20file%20%28.h%29%20aggiungere%0D%0A%2F%2F%20%23import%20%0D%0A%0D%0A%2F%2F%20Nell%27implementazione%20%0D%0A%2F%2F%20inserite%20l%27url%20de" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;t=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;annotation=Un%27alternativa%20davvero%20semplice%20per%20eseguire%20uno%20streaming%20di%20un%20file%20mp3%20su%20Apple%20iPhone%20potrebbe%20essere%3A%0D%0A%5Bobjc%5D%0D%0A%2F%2F%20Utilizzare%20AVFoundation%20Framework%20e%20nell%27header%20file%20%28.h%29%20aggiungere%0D%0A%2F%2F%20%23import%20%0D%0A%0D%0A%2F%2F%20Nell%27implementazione%20%0D%0A%2F%2F%20inserite%20l%27url%20de" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;headline=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Un%27alternativa%20davvero%20semplice%20per%20eseguire%20uno%20streaming%20di%20un%20file%20mp3%20su%20Apple%20iPhone%20potrebbe%20essere%3A%0D%0A%5Bobjc%5D%0D%0A%2F%2F%20Utilizzare%20AVFoundation%20Framework%20e%20nell%27header%20file%20%28.h%29%20aggiungere%0D%0A%2F%2F%20%23import%20%0D%0A%0D%0A%2F%2F%20Nell%27implementazione%20%0D%0A%2F%2F%20inserite%20l%27url%20de" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;t=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F&amp;title=Very%20short%20snippet%3A%20streaming%20mp3%20file%20su%20Apple%20iPhone" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F12%2F01%2Fvery-short-snippet-streaming-mp3-file-su-apple-iphone%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/apple-iphone/" title="Apple iPhone" rel="tag">Apple iPhone</a>, <a href="http://www.undolog.com/tag/avaudioplayer/" title="AVAudioPlayer" rel="tag">AVAudioPlayer</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/mp3/" title="mp3" rel="tag">mp3</a>, <a href="http://www.undolog.com/tag/nsdata/" title="NSData" rel="tag">NSData</a>, <a href="http://www.undolog.com/tag/nsurlconnection/" title="NSURLConnection" rel="tag">NSURLConnection</a>, <a href="http://www.undolog.com/tag/nsurlrequest/" title="NSURLRequest" rel="tag">NSURLRequest</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2010/02/25/iphone-eliminare-leffetto-ombra-durante-lo-scroll-in-un-uiwebview/" title="iPhone: eliminare l&#8217;effetto ombra durante lo scroll in un UIWebView (25 febbraio, 2010)">iPhone: eliminare l&#8217;effetto ombra durante lo scroll in un UIWebView</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/12/04/apple-iphone-creare-un-custom-toggle-button/" title="Apple iPhone: creare un custom toggle button (4 dicembre, 2009)">Apple iPhone: creare un custom toggle button</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/20/xcode-consigli-sul-debugging-preferences/" title="XCode: consigli sul Debugging Preferences (20 luglio, 2009)">XCode: consigli sul Debugging Preferences</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/12/01/very-short-snippet-streaming-mp3-file-su-apple-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Very short snippet: Apple iPhone file system</title>
		<link>http://www.undolog.com/2009/11/21/very-short-snippet-apple-iphone-file-system/</link>
		<comments>http://www.undolog.com/2009/11/21/very-short-snippet-apple-iphone-file-system/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 23:40:07 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Apple iPhone]]></category>
		<category><![CDATA[NSBundle]]></category>
		<category><![CDATA[NSDocumentDirectory]]></category>
		<category><![CDATA[NSFileManager]]></category>
		<category><![CDATA[NSFullUserName()]]></category>
		<category><![CDATA[NSHomeDirectory()]]></category>
		<category><![CDATA[NSHomeDirectoryForUser()]]></category>
		<category><![CDATA[NSSearchPathForDirectoriesInDomains()]]></category>
		<category><![CDATA[NSTemporaryDirectory()]]></category>
		<category><![CDATA[NSUserName()]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[stringByAppendingPathComponent]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2668</guid>
		<description><![CDATA[Sia sul Mac OS X che sull'iPhone OS, abbiamo la possibilità di accedere in modo semplice e diretto alle directory -  più importanti - di sistema, che sono:
PLAIN TEXT
CODE:




NSHomeDirectory &#160; &#160; &#160; &#160; Returns the path to the current user’s home directory.


NSHomeDirectoryForUser&#160; Returns the path to a given user’s home directory.


NSTemporaryDirectory&#160; &#160; Returns the [...]]]></description>
			<content:encoded><![CDATA[<p>Sia sul Mac OS X che sull'iPhone OS, abbiamo la possibilità di accedere in modo semplice e diretto alle directory -  più importanti - di sistema, che sono:</p>
<div class="igBar"><span id="lcode-85"><a href="#" onclick="javascript:showCodeTxt('code-85'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-85">
<div class="code" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSHomeDirectory &nbsp; &nbsp; &nbsp; &nbsp; Returns the path to the current user’s home directory.</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="">NSHomeDirectoryForUser</span>&nbsp; Returns the path to a given user’s home directory.</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="">NSTemporaryDirectory</span>&nbsp; &nbsp; Returns the path of the temporary directory for the current user.</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ecco il codice necessario per utilizzarle:</p>
<div class="igBar"><span id="lobjc-86"><a href="#" onclick="javascript:showCodeTxt('objc-86'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-86">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Directory principali</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>homePath <span style="color: #002200;">=</span> NSHomeDirectory<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>tempPath <span style="color: #002200;">=</span> NSTemporaryDirectory<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>userPath <span style="color: #002200;">=</span> NSHomeDirectoryForUser<span style="color: #002200;">&#40;</span> NSUserName<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;homePath = %@&quot;</span>, homePath<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;tempPath = %@&quot;</span>, tempPath<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;userPath = %@&quot;</span>, userPath<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// homePath = /var/mobile/Applications/C7B94C13-DCEC-40CD-942F-93FD302BF905</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// tempPath = /private/var/mobile/Applications/C7B94C13-DCEC-40CD-942F-93FD302BF905/tmp/</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// userPath = /var/mobile/Applications/C7B94C13-DCEC-40CD-942F-93FD302BF905</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<blockquote><p><strong>Nota</strong>: avete notato, riga 4, la chiamata a <code>NSUserName()</code> che ritorna il "current user"</p></blockquote>
<p>Esistono, poi, tutta una serie di altre "cartelle" a cui possiamo accedere. Queste possono essere ottenute attraverso la chiamata alla funzione <code>NSSearchPathForDirectoriesInDomains()</code> passandogli come inputs una serie di costanti. Ad esempio possiamo ottenere la cartella <strong>Documents</strong> in questo modo:</p>
<div class="igBar"><span id="lobjc-87"><a href="#" onclick="javascript:showCodeTxt('objc-87'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-87">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> <span style="color: #002200;">*</span>paths <span style="color: #002200;">=</span> NSSearchPathForDirectoriesInDomains<span style="color: #002200;">&#40;</span>NSDocumentDirectory, NSUserDomainMask, <span style="color: #a61390;">YES</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;paths = %@&quot;</span>, paths<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// paths = ( &quot;/var/mobile/Applications/C7B94C13-DCEC-40CD-942F-93FD302BF905/Documents&quot; )</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Cartella Documents</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>documentsPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>paths objectAtIndex<span style="color: #002200;">:</span>0<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;documentsPath = %@&quot;</span>, documentsPath<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// documentsPath = /var/mobile/Applications/C7B94C13-DCEC-40CD-942F-93FD302BF905/Documents</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Oppure...</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>documentsDirectory <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSHomeDirectory<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Documents&quot;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;documentsDirectory = %@&quot;</span>, documentsDirectory<span style="color: #002200;">&#41;</span>;&nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// documentsDirectory = /var/mobile/Applications/C7B94C13-DCEC-40CD-942F-93FD302BF905/Documents</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<blockquote><p><strong>Nota</strong>: in questo ultimo caso notate l'uso di <code>stringByAppendingPathComponent</code> che "concatena" Documents al path, aggiungendo lo slash</p></blockquote>
<p><code>NSSearchPathForDirectoriesInDomains()</code> ritorna sempre un array di stringhe, anche se nella maggiornaza dei casi gli elementi sono solo uno. Se guardate bene l'output di <code>paths</code>, infatti, viene indicato tra parentesi, cioè un'array. Nel primo caso viene estratto il primo elemento con <code>[paths objectAtIndex:0]</code>.</p>
<h4>Risorse</h4>
<p>Tramite l'oggetto <code>NSBundle</code>, invece, accediamo alla cartella delle risorse di una applicazione; come già sapete, l'estensione <code>.app</code> delle applicazioni Mac è "virtuale", per non dire fittizia. Essa, infatti, cela una sorta di "cartella" con all'interno tutte le risorse necessarie all'applicazione stessa, tra cui l'eseguibile vero e proprio! <img src='http://www.undolog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="igBar"><span id="lobjc-88"><a href="#" onclick="javascript:showCodeTxt('objc-88'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-88">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Applicazione</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>appFolderPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span> resourcePath<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;appFolderPath = %@&quot;</span>, appFolderPath<span style="color: #002200;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// appFolderPath = /var/mobile/Applications/54A1A3C9-322E-4C23-B096-45869B0332A5/MyApp.app</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Elencare il contenuto di una cartella (browsing)</h4>
<p>Il File Management, gestito dall'oggetto <a target="_blank" href="http://developer.apple.com/iPhone/library/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html"><code>NSFileManager</code></a>, permette di eseguire moltissime utili operazioni come:</p>
<ul>
<li>Creare directory e file</li>
<li>Copiare, spostare e "linkare" file e directory</li>
<li>Confrontare file e directory</li>
<li>Ottenere il contenuto di directory</li>
<li>e altro ancora...</li>
</ul>
<p>Ad esempio...</p>
<div class="igBar"><span id="lobjc-89"><a href="#" onclick="javascript:showCodeTxt('objc-89'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-89">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Elenco Directory</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> &nbsp; &nbsp; &nbsp;<span style="color: #002200;">*</span>homePath &nbsp; &nbsp;<span style="color: #002200;">=</span> NSHomeDirectory<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/"><span style="color: #400080;">NSFileManager</span></a> <span style="color: #002200;">*</span>fileManager <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/"><span style="color: #400080;">NSFileManager</span></a> defaultManager<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;La cartella %@ contiene = %@&quot;</span>, homePath, <span style="color: #002200;">&#91;</span>fileManager directoryContentsAtPath<span style="color: #002200;">:</span> homePath<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// La cartella /var/mobile/Applications/C7B94C13-DCEC-40CD-942F-93FD302BF905/ contiene = (</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Documents,</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Library,</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &quot;MyApp.app&quot;,</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// tmp</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// )</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Bonus</h4>
<p>Per quanto riguarda le informazioni "utente" abbiammo:</p>
<div class="igBar"><span id="lobjc-90"><a href="#" onclick="javascript:showCodeTxt('objc-90'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-90">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// FullUserName</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>fullUserName <span style="color: #002200;">=</span> NSFullUserName<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;fullUserName = %@&quot;</span>, fullUserName<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// fullUserName = Mobile User</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// NSUserName</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>userName <span style="color: #002200;">=</span> NSUserName<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;userName = %@&quot;</span>, userName<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// userName = mobile</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// NSHomeDirectoryForUser</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>directoryForUser <span style="color: #002200;">=</span> NSHomeDirectoryForUser<span style="color: #002200;">&#40;</span> userName <span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;directoryForUser = %@&quot;</span>, directoryForUser<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// directoryForUser = /var/mobile/Applications/DFD6AED2-6B14-4515-8DCD-2AF6F6C2E00C</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Lascio a voi provare le "differenze" tra l'uso del simulatore e il device.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;bodytext=Sia%20sul%20Mac%20OS%20X%20che%20sull%27iPhone%20OS%2C%20abbiamo%20la%20possibilit%C3%A0%20di%20accedere%20in%20modo%20semplice%20e%20diretto%20alle%20directory%20-%20%20pi%C3%B9%20importanti%20-%20di%20sistema%2C%20che%20sono%3A%0D%0A%5Bcode%5D%0D%0ANSHomeDirectory%09%20%20%20%20%20%20%20%20Returns%20the%20path%20to%20the%20current%20user%E2%80%99s%20home%20directory.%0D%0AN" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;notes=Sia%20sul%20Mac%20OS%20X%20che%20sull%27iPhone%20OS%2C%20abbiamo%20la%20possibilit%C3%A0%20di%20accedere%20in%20modo%20semplice%20e%20diretto%20alle%20directory%20-%20%20pi%C3%B9%20importanti%20-%20di%20sistema%2C%20che%20sono%3A%0D%0A%5Bcode%5D%0D%0ANSHomeDirectory%09%20%20%20%20%20%20%20%20Returns%20the%20path%20to%20the%20current%20user%E2%80%99s%20home%20directory.%0D%0AN" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;t=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;annotation=Sia%20sul%20Mac%20OS%20X%20che%20sull%27iPhone%20OS%2C%20abbiamo%20la%20possibilit%C3%A0%20di%20accedere%20in%20modo%20semplice%20e%20diretto%20alle%20directory%20-%20%20pi%C3%B9%20importanti%20-%20di%20sistema%2C%20che%20sono%3A%0D%0A%5Bcode%5D%0D%0ANSHomeDirectory%09%20%20%20%20%20%20%20%20Returns%20the%20path%20to%20the%20current%20user%E2%80%99s%20home%20directory.%0D%0AN" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;headline=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Sia%20sul%20Mac%20OS%20X%20che%20sull%27iPhone%20OS%2C%20abbiamo%20la%20possibilit%C3%A0%20di%20accedere%20in%20modo%20semplice%20e%20diretto%20alle%20directory%20-%20%20pi%C3%B9%20importanti%20-%20di%20sistema%2C%20che%20sono%3A%0D%0A%5Bcode%5D%0D%0ANSHomeDirectory%09%20%20%20%20%20%20%20%20Returns%20the%20path%20to%20the%20current%20user%E2%80%99s%20home%20directory.%0D%0AN" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;t=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F&amp;title=Very%20short%20snippet%3A%20Apple%20iPhone%20file%20system" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F21%2Fvery-short-snippet-apple-iphone-file-system%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/apple-iphone/" title="Apple iPhone" rel="tag">Apple iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/nsbundle/" title="NSBundle" rel="tag">NSBundle</a>, <a href="http://www.undolog.com/tag/nsdocumentdirectory/" title="NSDocumentDirectory" rel="tag">NSDocumentDirectory</a>, <a href="http://www.undolog.com/tag/nsfilemanager/" title="NSFileManager" rel="tag">NSFileManager</a>, <a href="http://www.undolog.com/tag/nsfullusername/" title="NSFullUserName()" rel="tag">NSFullUserName()</a>, <a href="http://www.undolog.com/tag/nshomedirectory/" title="NSHomeDirectory()" rel="tag">NSHomeDirectory()</a>, <a href="http://www.undolog.com/tag/nshomedirectoryforuser/" title="NSHomeDirectoryForUser()" rel="tag">NSHomeDirectoryForUser()</a>, <a href="http://www.undolog.com/tag/nssearchpathfordirectoriesindomains/" title="NSSearchPathForDirectoriesInDomains()" rel="tag">NSSearchPathForDirectoriesInDomains()</a>, <a href="http://www.undolog.com/tag/nstemporarydirectory/" title="NSTemporaryDirectory()" rel="tag">NSTemporaryDirectory()</a>, <a href="http://www.undolog.com/tag/nsusername/" title="NSUserName()" rel="tag">NSUserName()</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/snippets/" title="Snippets" rel="tag">Snippets</a>, <a href="http://www.undolog.com/tag/stringbyappendingpathcomponent/" title="stringByAppendingPathComponent" rel="tag">stringByAppendingPathComponent</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/10/09/very-short-snippet-iphone-numeri-casuali/" title="Very short snippet: iPhone, numeri casuali (9 ottobre, 2009)">Very short snippet: iPhone, numeri casuali</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/16/very-short-trick-fermare-nstimer/" title="Very short trick: fermare NSTimer (16 giugno, 2009)">Very short trick: fermare NSTimer</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/12/01/very-short-snippet-streaming-mp3-file-su-apple-iphone/" title="Very short snippet: streaming mp3 file su Apple iPhone (1 dicembre, 2009)">Very short snippet: streaming mp3 file su Apple iPhone</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/11/21/very-short-snippet-apple-iphone-file-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 utili trucchi e snippet per Apple iPhone e Xcode</title>
		<link>http://www.undolog.com/2009/11/12/10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode/</link>
		<comments>http://www.undolog.com/2009/11/12/10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 20:40:17 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Activity Indicator]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Camera]]></category>
		<category><![CDATA[Device]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[iPod Touch]]></category>
		<category><![CDATA[Localizzazione]]></category>
		<category><![CDATA[Reachability]]></category>
		<category><![CDATA[Snipp]]></category>
		<category><![CDATA[tips-&-tricks]]></category>
		<category><![CDATA[UIActivityIndicatorView]]></category>
		<category><![CDATA[UIApplication]]></category>
		<category><![CDATA[UIDevice]]></category>
		<category><![CDATA[UIImagePickerController]]></category>
		<category><![CDATA[UIWebView]]></category>
		<category><![CDATA[ViewController]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2645</guid>
		<description><![CDATA[Utilissimi snippet e trick per gli sviluppatori Apple iPhone, Xcode e Objective-C]]></description>
			<content:encoded><![CDATA[<h4>1. Stringhe su più righe</h4>
<p>In Xcode è possibile "spezzare" un stringa su più righe inserendo a alla fine un backslash "\". Questa caratteristica può risultare utilissima quando, ad esempio, vogliamo inserire del testo HTML in un controllo <strong><code>UIWebView</code></strong>:</p>
<div class="igBar"><span id="lobjc-91"><a href="#" onclick="javascript:showCodeTxt('objc-91'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-91">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>htmlData <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;html&gt;&lt;head&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;style type=<span style="color: #2400d9;">\&quot;</span>text/css<span style="color: #2400d9;">\&quot;</span>&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">body {background:#000;color:#fff} <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;/style&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;title&gt;Report&lt;/title&gt;&lt;/head&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;body&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;h1&gt;Prova HTML&lt;/h1&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;ul&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;li&gt;Testo HTML&lt;/li&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;li&gt;Inserito su&lt;/li&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;li&gt;piu' righe&lt;/li&gt; <span style="color: #2400d9;">\</span></span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #bf1d1a;">&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;&quot;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>webView loadHTMLString<span style="color: #002200;">:</span>htmlData baseURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.saidmade.com/&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>2. Transizioni tra View con effetto "foglio piegato"</h4>
<p>Ecco una funzione utile per sfogliare, e risflogliare, due <code>UIView</code>:</p>
<div class="igBar"><span id="lobjc-92"><a href="#" onclick="javascript:showCodeTxt('objc-92'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-92">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Esegue una transizione con effetto CURL da una UIView a una UIView</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// @params &nbsp;placeholder &nbsp; &nbsp; &nbsp; &nbsp; (UIView) principale</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// @params &nbsp;fview &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (UIView) di partenza</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// @params &nbsp;tview &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (UIView) di arrivo</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// @params &nbsp;forward &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (BOOL) sfoglia verso l'alto o verso il basso</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>makeTansitionFromView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWindow <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>placeholder fromView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>fview toView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tview forward<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>forward <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>1.5<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationTransition<span style="color: #002200;">:</span>forward?UIViewAnimationTransitionCurlUp<span style="color: #002200;">:</span>UIViewAnimationTransitionCurlDown forView<span style="color: #002200;">:</span>placeholder cache<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>tview removeFromSuperview<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>placeholder addSubview<span style="color: #002200;">:</span>fview<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>fview removeFromSuperview<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>placeholder addSubview<span style="color: #002200;">:</span>tview<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Può essere utilizzata in questo modo:</p>
<div class="igBar"><span id="lobjc-93"><a href="#" onclick="javascript:showCodeTxt('objc-93'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-93">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// visualizzo - sfoglio in avanti</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>self makeTansitionFromView<span style="color: #002200;">:</span>window fromView<span style="color: #002200;">:</span>primaView.view toView<span style="color: #002200;">:</span>secondaView.view forward<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// nascondo - sfoglio indietro</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>self makeTansitionFromView<span style="color: #002200;">:</span>window fromView<span style="color: #002200;">:</span>secondaView.view toView<span style="color: #002200;">:</span>primaView.view forward<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>3. Impedire l'auto oscuramento del display</h4>
<p>Da usare con cura, pena il consumo immediato della batteria, questa riga di codice permette di mantenere la nostra applicazione sempre visibile, impedendo che l'Apple iPhone vada in "stand-by":</p>
<div class="igBar"><span id="lobjc-94"><a href="#" onclick="javascript:showCodeTxt('objc-94'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-94">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span>.idleTimerDisabled <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>4. Network Activity Indicator</h4>
<p>L'animazione che compare sulla barra di stato in alto allo schermo dell'Apple iPhone, può essere utilizzata anche nelle nostre applicazioni per sottolineare un'attività di rete:</p>
<div class="igBar"><span id="lobjc-95"><a href="#" onclick="javascript:showCodeTxt('objc-95'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-95">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Mostra Network Activity Indicator ...</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span>.networkActivityIndicatorVisible <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Le tue operazioni ...</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Nasconde Network Activity Indicator ...</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span>.networkActivityIndicatorVisible <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>5. Activity Indicator personale</h4>
<p>Se non si dispone della barra di stato, può tornare utile mostrare un nostro <strong>Activity Indicator</strong>:</p>
<div class="igBar"><span id="lobjc-96"><a href="#" onclick="javascript:showCodeTxt('objc-96'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-96">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// globale da qualche parte... dipo in un Delegate (.h)</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIActivityIndicatorView <span style="color: #002200;">*</span>activity;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Nella loadView o viewDidLoad inizializziamo l'Activity Indicator </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">activity <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIActivityIndicatorView alloc<span style="color: #002200;">&#93;</span> initWithActivityIndicatorStyle<span style="color: #002200;">:</span>UIActivityIndicatorViewStyleWhite<span style="color: #002200;">&#93;</span>;&nbsp; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>activity<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>activity setCenter<span style="color: #002200;">:</span>CGPointMake<span style="color: #002200;">&#40;</span>160, 240<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>activity stopAnimating<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Quando ci serve</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>someMethod <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>activity startAnimating<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// to doing...</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>activity stopAnimating<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>6. Localizzazione</h3>
<p>Tramite questo snippet è possibile capire in che "lingua" è impostato il nostro device:</p>
<div class="igBar"><span id="lobjc-97"><a href="#" onclick="javascript:showCodeTxt('objc-97'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-97">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Checking language and localization</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/"><span style="color: #400080;">NSUserDefaults</span></a> &nbsp;<span style="color: #002200;">*</span>defaults &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/"><span style="color: #400080;">NSUserDefaults</span></a> standardUserDefaults<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">*</span>languages &nbsp; &nbsp; &nbsp; <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>defaults objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;AppleLanguages&quot;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #002200;">*</span>currentLanguage <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>languages objectAtIndex<span style="color: #002200;">:</span>0<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Current Locale: %@&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSLocale_Class/"><span style="color: #400080;">NSLocale</span></a> currentLocale<span style="color: #002200;">&#93;</span> localeIdentifier<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Current language: %@&quot;</span>, currentLanguage<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>7. iPhone o iPod?</h4>
<p>Questa classe è utilissima per determinare su quale dispositivo Apple sta funzionando la nostra applicazione. Non solo possiamo determinare il modello (iPhone o iPod Touch) ma anche la versione. Create due file <code>UIDevice-hardware.h</code> e <code>UIDevice-hardware.m</code>:</p>
<div class="igBar"><span id="lobjc-98"><a href="#" onclick="javascript:showCodeTxt('objc-98'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-98">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// UIDevice-hardware.h</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define IPHONE_1G_NAMESTRING @&quot;iPhone 1G&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define IPHONE_3G_NAMESTRING @&quot;iPhone 3G&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define IPHONE_3GS_NAMESTRING @&quot;iPhone 3GS&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define IPOD_1G_NAMESTRING @&quot;iPod touch 1G&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define IPOD_2G_NAMESTRING @&quot;iPod touch 2G&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@interface</span> UIDevice <span style="color: #002200;">&#40;</span>Hardware<span style="color: #002200;">&#41;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> platform;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> platformString;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@end</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lobjc-99"><a href="#" onclick="javascript:showCodeTxt('objc-99'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-99">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// UIDevice-hardware.m</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &quot;UIDevice-hardware.h&quot;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#include &lt;sys/types.h&gt;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#include &lt;sys/sysctl.h&gt;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@implementation</span> UIDevice <span style="color: #002200;">&#40;</span>Hardware<span style="color: #002200;">&#41;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">/*</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">&nbsp;Platforms</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">&nbsp;iPhone1,1 = iPhone 1G</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">&nbsp;iPhone1,2 = iPhone 3G</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">&nbsp;iPhone2,1 = iPhone 3GS</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">&nbsp;iPod1,1 &nbsp; = iPod touch 1G</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">&nbsp;iPod2,1 &nbsp; = iPod touch 2G</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">&nbsp;*/</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> platform <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">size_t</span> size;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; sysctlbyname<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;hw.machine&quot;</span>, <span style="color: #a61390;">NULL</span>, <span style="color: #002200;">&amp;</span>size, <span style="color: #a61390;">NULL</span>, 0<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">char</span> <span style="color: #002200;">*</span>machine <span style="color: #002200;">=</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/malloc.html"><span style="color: #a61390;">malloc</span></a><span style="color: #002200;">&#40;</span>size<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; ysctlbyname<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;hw.machine&quot;</span>, machine, <span style="color: #002200;">&amp;</span>size, <span style="color: #a61390;">NULL</span>, 0<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>platform <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithCString<span style="color: #002200;">:</span>machine<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/free.html"><span style="color: #a61390;">free</span></a><span style="color: #002200;">&#40;</span>machine<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">return</span> platform;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> platformString <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>platform <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self platform<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>platform isEqualToString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;iPhone1,1&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> IPHONE_1G_NAMESTRING;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>platform isEqualToString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;iPhone1,2&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> IPHONE_3G_NAMESTRING;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>platform isEqualToString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;iPhone2,1&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> IPHONE_3GS_NAMESTRING;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>platform isEqualToString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;iPod1,1&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> &nbsp; <span style="color: #a61390;">return</span> IPOD_1G_NAMESTRING;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>platform isEqualToString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;iPod2,1&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> &nbsp; <span style="color: #a61390;">return</span> IPOD_2G_NAMESTRING;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #a61390;">NULL</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@end</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Nel nostro <strong>Delegate</strong> possiamo inserire:</p>
<div class="igBar"><span id="lobjc-100"><a href="#" onclick="javascript:showCodeTxt('objc-100'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-100">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &quot;UIDevice-hardware.h&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>checkDeviceTypeAndCapabilities <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;type: %@&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIDevice currentDevice<span style="color: #002200;">&#93;</span> platform<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;type: %@&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIDevice currentDevice<span style="color: #002200;">&#93;</span> platformString<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>8. Camera</h4>
<p>Quando si scrive un'applicazione che usa l'accesso alle funzioni della <strong>Camera</strong> è bene verificare che il "device" supporti tali funzionalità (come da direttive Apple):</p>
<div class="igBar"><span id="lobjc-101"><a href="#" onclick="javascript:showCodeTxt('objc-101'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-101">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIImagePickerController <span style="color: #002200;">*</span>imgPicker;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>UIImagePickerController isSourceTypeAvailable<span style="color: #002200;">:</span>UIImagePickerControllerSourceTypeCamera<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; self.imgPicker.sourceType <span style="color: #002200;">=</span> UIImagePickerControllerSourceTypeCamera;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self presentModalViewController<span style="color: #002200;">:</span>self.imgPicker animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>9. Photo Album &#038; Photo Library</h4>
<p>Similmente a quello che accade con la <strong>Camera</strong>, è bene effettuare gli giusti controlli anche quando si accede alla libreria delle immagini:</p>
<div class="igBar"><span id="lobjc-102"><a href="#" onclick="javascript:showCodeTxt('objc-102'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-102">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIImagePickerController <span style="color: #002200;">*</span>imgPicker;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>UIImagePickerController isSourceTypeAvailable<span style="color: #002200;">:</span>UIImagePickerControllerSourceTypeSavedPhotosAlbum<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; self.imgPicker.sourceType <span style="color: #002200;">=</span> UIImagePickerControllerSourceTypeSavedPhotosAlbum;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self presentModalViewController<span style="color: #002200;">:</span>self.imgPicker animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// oppure ... &nbsp; </span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>UIImagePickerController isSourceTypeAvailable<span style="color: #002200;">:</span>UIImagePickerControllerSourceTypePhotoLibrary<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; self.imgPicker.sourceType <span style="color: #002200;">=</span> UIImagePickerControllerSourceTypePhotoLibrary;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self presentModalViewController<span style="color: #002200;">:</span>self.imgPicker animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>10. Disponibilità e tipo di rete</h4>
<p>Fortunatamente Apple ha scritto per noi una classe per determinare lo stato della rete. Questa può essere utilizzata nella nostra applicazione sia per verificare la presenza di rete che la sua tipologia: ethernet o WiFi. Scaricate <a target="_blank" href="https://developer.apple.com/iphone/library/samplecode/Reachability/listing1.html">Reachability.h</a> e <a target="_blank" href="https://developer.apple.com/iphone/library/samplecode/Reachability/listing2.html">Reachability.m</a>. Aggiungete il <strong>Framework</strong> <code>SystemConfiguration.framework</code>. A questo potete scrivere una funzione tipo:</p>
<div class="igBar"><span id="lobjc-103"><a href="#" onclick="javascript:showCodeTxt('objc-103'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-103">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// nel tuo Delegate .h</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">@class</span> Reachability;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// nel Delegate .m</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#import &quot;Reachability.h&quot;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Verifica copertura rete</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>CheckNetworkStatus <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Reachability reachabilityForInternetConnection<span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span> <span style="color: #002200;">!=</span> NotReachable<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Attenzione che il codice presente su Apple, il cui sorgente completo è reperibile in <a href="https://developer.apple.com/iphone/library/samplecode/Reachability/Reachability.zip">Reachability.zip</a>, è per le SDK 3.1.2. Se provate a compilare per le SDK 2.2.1 dovete commentare alcune parti di codici non supportate dalle "vecchie" (anche se ancora presenti) SDK; come le define:</p>
<div class="igBar"><span id="lobjc-104"><a href="#" onclick="javascript:showCodeTxt('objc-104'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-104">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">kSCNetworkReachabilityFlagsConnectionOnTraffic</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">kSCNetworkReachabilityFlagsConnectionOnDemand</div>
</li>
</ol>
</div>
</div>
</div>
<p>
e la parte di codice (da commentare):</p>
<div class="igBar"><span id="lobjc-105"><a href="#" onclick="javascript:showCodeTxt('objc-105'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-105">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp;if ((((flags &amp; kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp;(flags &amp; kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp;{</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp; // ... and the connection is on-demand (or on-traffic) if the</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; &nbsp; calling application is using the CFSocketStream or higher APIs</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//&nbsp; &nbsp; &nbsp; </span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp; if ((flags &amp; kSCNetworkReachabilityFlagsInterventionRequired) == 0)</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// ... and no [user] intervention is needed</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;retVal = ReachableViaWiFi;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// &nbsp; &nbsp; }</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;bodytext=Utilissimi%20snippet%20e%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone%2C%20Xcode%20e%20Objective-C" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;notes=Utilissimi%20snippet%20e%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone%2C%20Xcode%20e%20Objective-C" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;t=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;annotation=Utilissimi%20snippet%20e%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone%2C%20Xcode%20e%20Objective-C" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;headline=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Utilissimi%20snippet%20e%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone%2C%20Xcode%20e%20Objective-C" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;t=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F&amp;title=10%20utili%20trucchi%20e%20snippet%20per%20Apple%20iPhone%20e%20Xcode" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F12%2F10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/activity-indicator/" title="Activity Indicator" rel="tag">Activity Indicator</a>, <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/camera/" title="Camera" rel="tag">Camera</a>, <a href="http://www.undolog.com/tag/device/" title="Device" rel="tag">Device</a>, <a href="http://www.undolog.com/category/featured/" title="Featured" rel="tag">Featured</a>, <a href="http://www.undolog.com/tag/framework/" title="Framework" rel="tag">Framework</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/tag/ipod/" title="iPod" rel="tag">iPod</a>, <a href="http://www.undolog.com/tag/ipod-touch/" title="iPod Touch" rel="tag">iPod Touch</a>, <a href="http://www.undolog.com/tag/localizzazione/" title="Localizzazione" rel="tag">Localizzazione</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/reachability/" title="Reachability" rel="tag">Reachability</a>, <a href="http://www.undolog.com/tag/snipp/" title="Snipp" rel="tag">Snipp</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/tips-tricks/" title="tips-&amp;-tricks" rel="tag">tips-&amp;-tricks</a>, <a href="http://www.undolog.com/tag/uiactivityindicatorview/" title="UIActivityIndicatorView" rel="tag">UIActivityIndicatorView</a>, <a href="http://www.undolog.com/tag/uiapplication/" title="UIApplication" rel="tag">UIApplication</a>, <a href="http://www.undolog.com/tag/uidevice/" title="UIDevice" rel="tag">UIDevice</a>, <a href="http://www.undolog.com/tag/uiimagepickercontroller/" title="UIImagePickerController" rel="tag">UIImagePickerController</a>, <a href="http://www.undolog.com/tag/uiwebview/" title="UIWebView" rel="tag">UIWebView</a>, <a href="http://www.undolog.com/tag/viewcontroller/" title="ViewController" rel="tag">ViewController</a>, <a href="http://www.undolog.com/tag/xcode/" title="XCode" rel="tag">XCode</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/10/28/very-short-trick-3-trick-per-gli-sviluppatori-apple-iphone/" title="Very short trick: 3 trick per gli sviluppatori Apple iPhone (28 ottobre, 2009)">Very short trick: 3 trick per gli sviluppatori Apple iPhone</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/13/iphone-secondapp-indovina-il-numero-parte-2/" title="iPhone SecondApp: indovina il numero &#8211; parte 2 (13 luglio, 2009)">iPhone SecondApp: indovina il numero &#8211; parte 2</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/23/iphone-firstapp-indovina-il-numero-parte-1/" title="iPhone FirstApp: indovina il numero &#8211; parte 1 (23 giugno, 2009)">iPhone FirstApp: indovina il numero &#8211; parte 1</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/11/12/10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Very short snippet: formattare un data di un controllo UIDatePicker</title>
		<link>http://www.undolog.com/2009/11/06/very-short-snippet-formattare-un-data-di-un-controllo-uidatepicker/</link>
		<comments>http://www.undolog.com/2009/11/06/very-short-snippet-formattare-un-data-di-un-controllo-uidatepicker/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 10:28:38 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Device]]></category>
		<category><![CDATA[Format]]></category>
		<category><![CDATA[NSDateFormatter]]></category>
		<category><![CDATA[SDK 2.2.1]]></category>
		<category><![CDATA[Snipp]]></category>
		<category><![CDATA[UIDatePicker]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2633</guid>
		<description><![CDATA[Il controllo UIDatePicker è forse il più bel controllo grafico presente su Apple iPhone. Oltre alla bellezza risulta anche semplice da utilizzare, versatile ed estremamente utilizzato in moltissime situazioni. 

Diventa quindi importate saper "leggere" la data impostata nel controllo:
PLAIN TEXT
Objective-C:




// questo metodo funziona sia sul Simulatore sia sul Device (SDK 2.2.1)


NSDate *date = dateInsert.date;


NSDateFormatter *dateFormat [...]]]></description>
			<content:encoded><![CDATA[<p>Il controllo <code>UIDatePicker</code> è forse il più bel controllo grafico presente su Apple iPhone. Oltre alla bellezza risulta anche semplice da utilizzare, versatile ed estremamente utilizzato in moltissime situazioni. </p>
<p class="center"><img src="http://www.undolog.com/wp-content/uploads/2009/11/Immagine-17.png" alt="UIDatePicker" title="UIDatePicker" width="336" height="229" /></p>
<p>Diventa quindi importate saper "leggere" la data impostata nel controllo:</p>
<div class="igBar"><span id="lobjc-108"><a href="#" onclick="javascript:showCodeTxt('objc-108'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-108">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// questo metodo funziona sia sul Simulatore sia sul Device (SDK 2.2.1)</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/"><span style="color: #400080;">NSDate</span></a> <span style="color: #002200;">*</span>date <span style="color: #002200;">=</span> dateInsert.date;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/"><span style="color: #400080;">NSDateFormatter</span></a> <span style="color: #002200;">*</span>dateFormat <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/"><span style="color: #400080;">NSDateFormatter</span></a> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>dateFormat setDateFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;yyyy-MM-dd HH:mm&quot;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Data formattata: %@&quot;</span>, <span style="color: #002200;">&#91;</span>dateFormat stringFromDate<span style="color: #002200;">:</span>date<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lobjc-109"><a href="#" onclick="javascript:showCodeTxt('objc-109'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-109">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// anche questo funziona su entrambi, Simulatore e Device, ma quando lo si</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// compila per il Device emette un Warning</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// warning: 'NSDate' may not respond to '-descriptionWithCalendarFormat:timeZone:locale:'</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Data formattata: %@&quot;</span>, <span style="color: #002200;">&#91;</span>dateInsert.date descriptionWithCalendarFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%Y%m%d %H:%M&quot;</span> timeZone<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> locale<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;bodytext=Il%20controllo%20UIDatePicker%20%C3%A8%20forse%20il%20pi%C3%B9%20bel%20controllo%20grafico%20presente%20su%20Apple%20iPhone.%20Oltre%20alla%20bellezza%20risulta%20anche%20semplice%20da%20utilizzare%2C%20versatile%20ed%20estremamente%20utilizzato%20in%20moltissime%20situazioni.%20%0D%0A%0D%0ADiventa%20quindi%20importate%20saper%20%22le" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;notes=Il%20controllo%20UIDatePicker%20%C3%A8%20forse%20il%20pi%C3%B9%20bel%20controllo%20grafico%20presente%20su%20Apple%20iPhone.%20Oltre%20alla%20bellezza%20risulta%20anche%20semplice%20da%20utilizzare%2C%20versatile%20ed%20estremamente%20utilizzato%20in%20moltissime%20situazioni.%20%0D%0A%0D%0ADiventa%20quindi%20importate%20saper%20%22le" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;t=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;annotation=Il%20controllo%20UIDatePicker%20%C3%A8%20forse%20il%20pi%C3%B9%20bel%20controllo%20grafico%20presente%20su%20Apple%20iPhone.%20Oltre%20alla%20bellezza%20risulta%20anche%20semplice%20da%20utilizzare%2C%20versatile%20ed%20estremamente%20utilizzato%20in%20moltissime%20situazioni.%20%0D%0A%0D%0ADiventa%20quindi%20importate%20saper%20%22le" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;headline=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Il%20controllo%20UIDatePicker%20%C3%A8%20forse%20il%20pi%C3%B9%20bel%20controllo%20grafico%20presente%20su%20Apple%20iPhone.%20Oltre%20alla%20bellezza%20risulta%20anche%20semplice%20da%20utilizzare%2C%20versatile%20ed%20estremamente%20utilizzato%20in%20moltissime%20situazioni.%20%0D%0A%0D%0ADiventa%20quindi%20importate%20saper%20%22le" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;t=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F&amp;title=Very%20short%20snippet%3A%20formattare%20un%20data%20di%20un%20controllo%20UIDatePicker" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F11%2F06%2Fvery-short-snippet-formattare-un-data-di-un-controllo-uidatepicker%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/device/" title="Device" rel="tag">Device</a>, <a href="http://www.undolog.com/tag/format/" title="Format" rel="tag">Format</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/nsdateformatter/" title="NSDateFormatter" rel="tag">NSDateFormatter</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/sdk-2-2-1/" title="SDK 2.2.1" rel="tag">SDK 2.2.1</a>, <a href="http://www.undolog.com/tag/snipp/" title="Snipp" rel="tag">Snipp</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/uidatepicker/" title="UIDatePicker" rel="tag">UIDatePicker</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/11/12/10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode/" title="10 utili trucchi e snippet per Apple iPhone e Xcode (12 novembre, 2009)">10 utili trucchi e snippet per Apple iPhone e Xcode</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/02/xcode-3-1-3-ripristinare-le-sdk-2-2-1/" title="XCode 3.1.3: ripristinare le SDK 2.2.1 (2 luglio, 2009)">XCode 3.1.3: ripristinare le SDK 2.2.1</a> (0)</li>
	<li><a href="http://www.undolog.com/2008/10/31/very-short-snippet-php-plain-date/" title="Very short snippet: PHP plain date (31 ottobre, 2008)">Very short snippet: PHP plain date</a> (1)</li>
	<li><a href="http://www.undolog.com/2009/10/09/very-short-snippet-iphone-numeri-casuali/" title="Very short snippet: iPhone, numeri casuali (9 ottobre, 2009)">Very short snippet: iPhone, numeri casuali</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/02/11/very-short-snippet-formattare-valute-in-php/" title="Very short snippet: formattare valute in PHP (11 febbraio, 2009)">Very short snippet: formattare valute in PHP</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/11/06/very-short-snippet-formattare-un-data-di-un-controllo-uidatepicker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C: NSLog() su struct C</title>
		<link>http://www.undolog.com/2009/10/29/objective-c-nslog-su-struct-c/</link>
		<comments>http://www.undolog.com/2009/10/29/objective-c-nslog-su-struct-c/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 09:02:46 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[CGPoint]]></category>
		<category><![CDATA[CGRect]]></category>
		<category><![CDATA[NSLog()]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[NSStringFromCGRect()]]></category>
		<category><![CDATA[Object]]></category>
		<category><![CDATA[struct]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2582</guid>
		<description><![CDATA[La sintassi NSLog(@"%@", ... ); funziona ed è utilizzata per ottenere informazioni sugli oggetti, ma non funziona su tipi dato C come struct CGRect o CGPoint, ad esempio. Per poter sfruttare NSLog(@"%@", ... ); anche su struct di tipo C possiamo appoggiarci a funzioni di conversione come NSStringFromCGRect() o NSStringFromCGPoint:
PLAIN TEXT
Objective-C:




CGrect mioRect = &#40;CGRect&#41;&#123;10,20,30,40&#125;;


CGPoint mioPoint [...]]]></description>
			<content:encoded><![CDATA[<p>La sintassi <code>NSLog(@"%@", ... );</code> funziona ed è utilizzata per ottenere informazioni sugli oggetti, ma non funziona su tipi dato C come struct <code>CGRect</code> o <code>CGPoint</code>, ad esempio. Per poter sfruttare <code>NSLog(@"%@", ... );</code> anche su struct di tipo C possiamo appoggiarci a funzioni di conversione come <code>NSStringFromCGRect()</code> o <code>NSStringFromCGPoint</code>:</p>
<div class="igBar"><span id="lobjc-114"><a href="#" onclick="javascript:showCodeTxt('objc-114'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-114">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CGrect mioRect <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>10,20,30,40<span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CGPoint mioPoint <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>32,64<span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Info rettangolo: %@&quot;</span>, NSStringFromCGRect<span style="color: #002200;">&#40;</span>mioRect<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLog<span style="color: #002200;">&#40;</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Info point: %@&quot;</span>, NSStringFromCGPoint<span style="color: #002200;">&#40;</span>mioPoint<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Nello specifico è possibile perfezionare tale procedure scrivendosi delle piccole macro utili come:</p>
<div class="igBar"><span id="lobjc-115"><a href="#" onclick="javascript:showCodeTxt('objc-115'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-115">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define NSLogRect(rect) NSLog(@&quot;%s: (%0.0f, %0.0f) %0.0f x %0.0f&quot;, #rect, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Oppure:</p>
<div class="igBar"><span id="lobjc-116"><a href="#" onclick="javascript:showCodeTxt('objc-116'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-116">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6e371a;">#define NSLogCGPoint(point) NSLog(@&quot;%s: (%0.0f, %0.0f)&quot;, #point point.x, point.y)</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CGPoint mioPoint <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>32,64<span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">NSLogCGPoint<span style="color: #002200;">&#40;</span>mioPoint<span style="color: #002200;">&#41;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p>
Che darà come output:</p>
<div class="igBar"><span id="lobjc-117"><a href="#" onclick="javascript:showCodeTxt('objc-117'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-117">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">mioPoint<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><span style="color: #2400d9;color:#800000;">32</span>, <span style="color: #2400d9;color:#800000;">64</span><span style="color: #002200;">&#41;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;bodytext=La%20sintassi%20NSLog%28%40%22%25%40%22%2C%20...%20%29%3B%20funziona%20ed%20%C3%A8%20utilizzata%20per%20ottenere%20informazioni%20sugli%20oggetti%2C%20ma%20non%20funziona%20su%20tipi%20dato%20C%20come%20struct%20CGRect%20o%20CGPoint%2C%20ad%20esempio.%20Per%20poter%20sfruttare%20NSLog%28%40%22%25%40%22%2C%20...%20%29%3B%20anche%20su%20struct%20di%20tipo%20C%20possiamo%20app" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;notes=La%20sintassi%20NSLog%28%40%22%25%40%22%2C%20...%20%29%3B%20funziona%20ed%20%C3%A8%20utilizzata%20per%20ottenere%20informazioni%20sugli%20oggetti%2C%20ma%20non%20funziona%20su%20tipi%20dato%20C%20come%20struct%20CGRect%20o%20CGPoint%2C%20ad%20esempio.%20Per%20poter%20sfruttare%20NSLog%28%40%22%25%40%22%2C%20...%20%29%3B%20anche%20su%20struct%20di%20tipo%20C%20possiamo%20app" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;t=Objective-C%3A%20NSLog%28%29%20su%20struct%20C" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;annotation=La%20sintassi%20NSLog%28%40%22%25%40%22%2C%20...%20%29%3B%20funziona%20ed%20%C3%A8%20utilizzata%20per%20ottenere%20informazioni%20sugli%20oggetti%2C%20ma%20non%20funziona%20su%20tipi%20dato%20C%20come%20struct%20CGRect%20o%20CGPoint%2C%20ad%20esempio.%20Per%20poter%20sfruttare%20NSLog%28%40%22%25%40%22%2C%20...%20%29%3B%20anche%20su%20struct%20di%20tipo%20C%20possiamo%20app" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Objective-C%3A%20NSLog%28%29%20su%20struct%20C%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;headline=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=La%20sintassi%20NSLog%28%40%22%25%40%22%2C%20...%20%29%3B%20funziona%20ed%20%C3%A8%20utilizzata%20per%20ottenere%20informazioni%20sugli%20oggetti%2C%20ma%20non%20funziona%20su%20tipi%20dato%20C%20come%20struct%20CGRect%20o%20CGPoint%2C%20ad%20esempio.%20Per%20poter%20sfruttare%20NSLog%28%40%22%25%40%22%2C%20...%20%29%3B%20anche%20su%20struct%20di%20tipo%20C%20possiamo%20app" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;t=Objective-C%3A%20NSLog%28%29%20su%20struct%20C" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F&amp;title=Objective-C%3A%20NSLog%28%29%20su%20struct%20C" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F29%2Fobjective-c-nslog-su-struct-c%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/cgpoint/" title="CGPoint" rel="tag">CGPoint</a>, <a href="http://www.undolog.com/tag/cgrect/" title="CGRect" rel="tag">CGRect</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/nslog/" title="NSLog()" rel="tag">NSLog()</a>, <a href="http://www.undolog.com/tag/nsstring/" title="NSString" rel="tag">NSString</a>, <a href="http://www.undolog.com/tag/nsstringfromcgrect/" title="NSStringFromCGRect()" rel="tag">NSStringFromCGRect()</a>, <a href="http://www.undolog.com/tag/object/" title="Object" rel="tag">Object</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/struct/" title="struct" rel="tag">struct</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/27/objective-c-unalternativa-alluso-di-cgrectmake/" title="Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake (27 luglio, 2009)">Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake</a> (2)</li>
	<li><a href="http://www.undolog.com/2009/06/23/objective-c-conversione-dei-tipi/" title="Objective-C: conversione dei tipi (23 giugno, 2009)">Objective-C: conversione dei tipi</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/13/iphone-secondapp-indovina-il-numero-parte-2/" title="iPhone SecondApp: indovina il numero &#8211; parte 2 (13 luglio, 2009)">iPhone SecondApp: indovina il numero &#8211; parte 2</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/23/iphone-firstapp-indovina-il-numero-parte-1/" title="iPhone FirstApp: indovina il numero &#8211; parte 1 (23 giugno, 2009)">iPhone FirstApp: indovina il numero &#8211; parte 1</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/26/come-eliminare-nslog-dai-sorgenti-xcode/" title="Come eliminare NSLog() dai sorgenti XCode (26 giugno, 2009)">Come eliminare NSLog() dai sorgenti XCode</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/10/29/objective-c-nslog-su-struct-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Very short trick: 3 trick per gli sviluppatori Apple iPhone</title>
		<link>http://www.undolog.com/2009/10/28/very-short-trick-3-trick-per-gli-sviluppatori-apple-iphone/</link>
		<comments>http://www.undolog.com/2009/10/28/very-short-trick-3-trick-per-gli-sviluppatori-apple-iphone/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 13:06:11 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[tips-&-tricks]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2567</guid>
		<description><![CDATA[Icona applicazione
L'icona 57x57 pixel che andrà a rappresentare la nostra applicazione viene "alterata" automaticamente dall'Apple iPhone: viene aggiunto un bordo arrotondato, un effetto luminoso e 3D. Questa impostazione può essere cambiata selezionando il file [nome applicazione]-Info.plist e aggiungendo la property "Icon already includes gloss and bevel effects":

Fullscreen, eliminare la status bar
Sempre agendo sul file [nome [...]]]></description>
			<content:encoded><![CDATA[<h4>Icona applicazione</h4>
<p>L'icona 57x57 pixel che andrà a rappresentare la nostra applicazione viene "alterata" automaticamente dall'Apple iPhone: viene aggiunto un bordo arrotondato, un effetto luminoso e 3D. Questa impostazione può essere cambiata selezionando il file <code>[nome applicazione]-Info.plist</code> e aggiungendo la property <strong>"Icon already includes gloss and bevel effects"</strong>:</p>
<p class="center"><img style="border:1px solid #aaa" title="Icona applicazione" src="http://www.undolog.com/wp-content/uploads/2009/10/Immagine-1.png" alt="Icona applicazione" width="305" height="29" /></p>
<h4>Fullscreen, eliminare la status bar</h4>
<p>Sempre agendo sul file <code>[nome applicazione]-Info.plist</code> è possibile "nascondere" la barra di stato che si trova nella parte alta dello schermo, così da realizzare applicazioni in fullscreen. Anche in questo caso basta aggiungere la property <strong>"Status bar is initially hidden"</strong>:</p>
<p class="center"><img style="border:1px solid #aaa" title="Fullscreen, eliminare la status bar" src="http://www.undolog.com/wp-content/uploads/2009/10/Immagine-5.png" alt="Fullscreen, eliminare la status bar" width="306" height="31" /></p>
<h4>XCode: eliminare una riga</h4>
<p>Per eliminare una riga intera in XCode si può utilizzare la combinazione:<code> CTRL+A, CTRL+K, CTRL+K</code>.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;bodytext=Icona%20applicazione%0D%0AL%27icona%2057x57%20pixel%20che%20andr%C3%A0%20a%20rappresentare%20la%20nostra%20applicazione%20viene%20%22alterata%22%20automaticamente%20dall%27Apple%20iPhone%3A%20viene%20aggiunto%20un%20bordo%20arrotondato%2C%20un%20effetto%20luminoso%20e%203D.%20Questa%20impostazione%20pu%C3%B2%20essere%20cambiata%20sele" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;notes=Icona%20applicazione%0D%0AL%27icona%2057x57%20pixel%20che%20andr%C3%A0%20a%20rappresentare%20la%20nostra%20applicazione%20viene%20%22alterata%22%20automaticamente%20dall%27Apple%20iPhone%3A%20viene%20aggiunto%20un%20bordo%20arrotondato%2C%20un%20effetto%20luminoso%20e%203D.%20Questa%20impostazione%20pu%C3%B2%20essere%20cambiata%20sele" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;t=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;annotation=Icona%20applicazione%0D%0AL%27icona%2057x57%20pixel%20che%20andr%C3%A0%20a%20rappresentare%20la%20nostra%20applicazione%20viene%20%22alterata%22%20automaticamente%20dall%27Apple%20iPhone%3A%20viene%20aggiunto%20un%20bordo%20arrotondato%2C%20un%20effetto%20luminoso%20e%203D.%20Questa%20impostazione%20pu%C3%B2%20essere%20cambiata%20sele" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;headline=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Icona%20applicazione%0D%0AL%27icona%2057x57%20pixel%20che%20andr%C3%A0%20a%20rappresentare%20la%20nostra%20applicazione%20viene%20%22alterata%22%20automaticamente%20dall%27Apple%20iPhone%3A%20viene%20aggiunto%20un%20bordo%20arrotondato%2C%20un%20effetto%20luminoso%20e%203D.%20Questa%20impostazione%20pu%C3%B2%20essere%20cambiata%20sele" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;t=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F&amp;title=Very%20short%20trick%3A%203%20trick%20per%20gli%20sviluppatori%20Apple%20iPhone" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F28%2Fvery-short-trick-3-trick-per-gli-sviluppatori-apple-iphone%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/fullscreen/" title="fullscreen" rel="tag">fullscreen</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/tips-tricks/" title="tips-&amp;-tricks" rel="tag">tips-&amp;-tricks</a>, <a href="http://www.undolog.com/tag/trick/" title="trick" rel="tag">trick</a>, <a href="http://www.undolog.com/tag/xcode/" title="XCode" rel="tag">XCode</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/11/12/10-utili-trucchi-e-snippet-per-apple-iphone-e-xcode/" title="10 utili trucchi e snippet per Apple iPhone e Xcode (12 novembre, 2009)">10 utili trucchi e snippet per Apple iPhone e Xcode</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/20/xcode-consigli-sul-debugging-preferences/" title="XCode: consigli sul Debugging Preferences (20 luglio, 2009)">XCode: consigli sul Debugging Preferences</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/16/very-short-trick-fermare-nstimer/" title="Very short trick: fermare NSTimer (16 giugno, 2009)">Very short trick: fermare NSTimer</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/10/28/very-short-trick-3-trick-per-gli-sviluppatori-apple-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XCode Objective-C: abbreviazioni utili da tastiera</title>
		<link>http://www.undolog.com/2009/10/26/xcode-objective-c-abbreviazioni-utili-da-tastiera/</link>
		<comments>http://www.undolog.com/2009/10/26/xcode-objective-c-abbreviazioni-utili-da-tastiera/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 15:09:49 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Completamento automatico]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2554</guid>
		<description><![CDATA[XCode è davvero un ambiente di sviluppo potente e riserva sempre qualche sorpresa. Esso permette una funzione simile agli "snippet" del noto editor TextMate. In pratica è possibile inserire blocchi di codice utilizzando la sequenza tasto ESC + una combinazione di una o più sequenze di caratteri. Ad esempio se volete inserire un blocco if [...]]]></description>
			<content:encoded><![CDATA[<p>XCode è davvero un ambiente di sviluppo potente e riserva sempre qualche sorpresa. Esso permette una funzione simile agli "snippet" del noto editor <a href="http://macromates.com/" target="_blank">TextMate</a>. In pratica è possibile inserire blocchi di codice utilizzando la sequenza tasto ESC + una combinazione di una o più sequenze di caratteri. Ad esempio se volete inserire un blocco <code>if</code> prova a premere <code>ESC+if</code> e otterrete:</p>
<p class="aligncenter"><img style="border:1px solid #aaa" title="XCode" src="http://www.undolog.com/wp-content/uploads/2009/10/Immagine-3.png" alt="Immagine 3" width="286" height="101" /></p>
<p>Come mostrato in figura, appare un menu (lo stesso del completamento automatico) dove è possibile scegliere tra un semplice blocco <code>if</code> o <code>if/else</code>. Cliccando "invio" si ottiene:</p>
<p class="aligncenter"><img style="border:1px solid #aaa" title="XCode" src="http://www.undolog.com/wp-content/uploads/2009/10/Immagine-4.png" alt="Immagine 4" width="172" height="69" /></p>
<p>Ecco due link utili per avere la lista completa delle combinazioni da tastiera:</p>
<ul>
<li><a href="http://developer.apple.com/iphone/library/documentation/DeveloperTools/Conceptual/XcodeWorkspace/100-The_Text_Editor/text_editor.html#//apple_ref/doc/uid/TP40002679-SW35" target="_blank">Guida ufficiale Apple su XCode: sezione Macros</a></li>
<li><a href="http://www.mobileorchard.com/wp-content/uploads/2009/04/xcode-macros-cheatsheet.pdf" target="_blank">Un comodo e pratico PDF di una sola pagina con tutte le combinazioni</a></li>
</ul>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;bodytext=XCode%20%C3%A8%20davvero%20un%20ambiente%20di%20sviluppo%20potente%20e%20riserva%20sempre%20qualche%20sorpresa.%20Esso%20permette%20una%20funzione%20simile%20agli%20%22snippet%22%20del%20noto%20editor%20TextMate.%20In%20pratica%20%C3%A8%20possibile%20inserire%20blocchi%20di%20codice%20utilizzando%20la%20sequenza%20tasto%20ESC%20%2B%20una%20" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;notes=XCode%20%C3%A8%20davvero%20un%20ambiente%20di%20sviluppo%20potente%20e%20riserva%20sempre%20qualche%20sorpresa.%20Esso%20permette%20una%20funzione%20simile%20agli%20%22snippet%22%20del%20noto%20editor%20TextMate.%20In%20pratica%20%C3%A8%20possibile%20inserire%20blocchi%20di%20codice%20utilizzando%20la%20sequenza%20tasto%20ESC%20%2B%20una%20" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;t=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;annotation=XCode%20%C3%A8%20davvero%20un%20ambiente%20di%20sviluppo%20potente%20e%20riserva%20sempre%20qualche%20sorpresa.%20Esso%20permette%20una%20funzione%20simile%20agli%20%22snippet%22%20del%20noto%20editor%20TextMate.%20In%20pratica%20%C3%A8%20possibile%20inserire%20blocchi%20di%20codice%20utilizzando%20la%20sequenza%20tasto%20ESC%20%2B%20una%20" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;headline=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=XCode%20%C3%A8%20davvero%20un%20ambiente%20di%20sviluppo%20potente%20e%20riserva%20sempre%20qualche%20sorpresa.%20Esso%20permette%20una%20funzione%20simile%20agli%20%22snippet%22%20del%20noto%20editor%20TextMate.%20In%20pratica%20%C3%A8%20possibile%20inserire%20blocchi%20di%20codice%20utilizzando%20la%20sequenza%20tasto%20ESC%20%2B%20una%20" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;t=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F&amp;title=XCode%20Objective-C%3A%20abbreviazioni%20utili%20da%20tastiera" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F26%2Fxcode-objective-c-abbreviazioni-utili-da-tastiera%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/completamento-automatico/" title="Completamento automatico" rel="tag">Completamento automatico</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/tag/macros/" title="Macros" rel="tag">Macros</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/software/" title="Software" rel="tag">Software</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/xcode/" title="XCode" rel="tag">XCode</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/27/objective-c-unalternativa-alluso-di-cgrectmake/" title="Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake (27 luglio, 2009)">Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake</a> (2)</li>
	<li><a href="http://www.undolog.com/2009/06/29/iphone-tutti-i-font-di-sistema/" title="iPhone: tutti i font di sistema (29 giugno, 2009)">iPhone: tutti i font di sistema</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/13/iphone-secondapp-indovina-il-numero-parte-2/" title="iPhone SecondApp: indovina il numero &#8211; parte 2 (13 luglio, 2009)">iPhone SecondApp: indovina il numero &#8211; parte 2</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/10/26/xcode-objective-c-abbreviazioni-utili-da-tastiera/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Very short snippet: iPhone, numeri casuali</title>
		<link>http://www.undolog.com/2009/10/09/very-short-snippet-iphone-numeri-casuali/</link>
		<comments>http://www.undolog.com/2009/10/09/very-short-snippet-iphone-numeri-casuali/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 09:19:29 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[arc4random()]]></category>
		<category><![CDATA[numeri casuali]]></category>
		<category><![CDATA[Snipp]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2528</guid>
		<description><![CDATA[Se avete bisogno di generare numeri casuali in una applicazione Apple iPhone dovete mettere da parte Objective-C, in quanto non propone nessuna classe allo scopo. La soluzione viene dal C che propone: rand(), srand(), random(), srandom() e arc4random().
Tra tutte la più gettonata è sicuramente arc4random(), in quanto non richiede nessuna inizializzazione speciale o funzioni di [...]]]></description>
			<content:encoded><![CDATA[<p>Se avete bisogno di generare numeri casuali in una applicazione Apple iPhone dovete mettere da parte Objective-C, in quanto non propone nessuna classe allo scopo. La soluzione viene dal C che propone: <code>rand(), srand(), random(), srandom() e arc4random()</code>.<br />
Tra tutte la più gettonata è sicuramente <code>arc4random()</code>, in quanto non richiede nessuna inizializzazione speciale o funzioni di <em>seeding</em>, restituendo un buon valore "randomico"; potremmo dire che è <em>auto-inizializzante</em>.</p>
<div class="igBar"><span id="lobjc-119"><a href="#" onclick="javascript:showCodeTxt('objc-119'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-119">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Genera un numero casuale da 0 a 99</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">int</span> rnd <span style="color: #002200;">=</span> arc4random<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">%</span> <span style="color: #2400d9;color:#800000;">100</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// Genera un numero casuale da 20 a 50</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">int</span> rnd <span style="color: #002200;">=</span> &nbsp;<span style="color: #002200;">&#40;</span>arc4random<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">%</span> 51<span style="color: #002200;">&#41;</span> <span style="color: #002200;">+</span> <span style="color: #2400d9;color:#800000;">20</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;bodytext=Se%20avete%20bisogno%20di%20generare%20numeri%20casuali%20in%20una%20applicazione%20Apple%20iPhone%20dovete%20mettere%20da%20parte%20Objective-C%2C%20in%20quanto%20non%20propone%20nessuna%20classe%20allo%20scopo.%20La%20soluzione%20viene%20dal%20C%20che%20propone%3A%20rand%28%29%2C%20srand%28%29%2C%20random%28%29%2C%20srandom%28%29%20e%20arc4random" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;notes=Se%20avete%20bisogno%20di%20generare%20numeri%20casuali%20in%20una%20applicazione%20Apple%20iPhone%20dovete%20mettere%20da%20parte%20Objective-C%2C%20in%20quanto%20non%20propone%20nessuna%20classe%20allo%20scopo.%20La%20soluzione%20viene%20dal%20C%20che%20propone%3A%20rand%28%29%2C%20srand%28%29%2C%20random%28%29%2C%20srandom%28%29%20e%20arc4random" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;t=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;annotation=Se%20avete%20bisogno%20di%20generare%20numeri%20casuali%20in%20una%20applicazione%20Apple%20iPhone%20dovete%20mettere%20da%20parte%20Objective-C%2C%20in%20quanto%20non%20propone%20nessuna%20classe%20allo%20scopo.%20La%20soluzione%20viene%20dal%20C%20che%20propone%3A%20rand%28%29%2C%20srand%28%29%2C%20random%28%29%2C%20srandom%28%29%20e%20arc4random" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;headline=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Se%20avete%20bisogno%20di%20generare%20numeri%20casuali%20in%20una%20applicazione%20Apple%20iPhone%20dovete%20mettere%20da%20parte%20Objective-C%2C%20in%20quanto%20non%20propone%20nessuna%20classe%20allo%20scopo.%20La%20soluzione%20viene%20dal%20C%20che%20propone%3A%20rand%28%29%2C%20srand%28%29%2C%20random%28%29%2C%20srandom%28%29%20e%20arc4random" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;t=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F&amp;title=Very%20short%20snippet%3A%20iPhone%2C%20numeri%20casuali" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F09%2Fvery-short-snippet-iphone-numeri-casuali%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/arc4random/" title="arc4random()" rel="tag">arc4random()</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/numeri-casuali/" title="numeri casuali" rel="tag">numeri casuali</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/snipp/" title="Snipp" rel="tag">Snipp</a>, <a href="http://www.undolog.com/tag/snippets/" title="Snippets" rel="tag">Snippets</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/16/very-short-trick-fermare-nstimer/" title="Very short trick: fermare NSTimer (16 giugno, 2009)">Very short trick: fermare NSTimer</a> (0)</li>
	<li><a href="http://www.undolog.com/2010/02/05/very-short-snippet-ottenere-loutput-di-un-url-in-objective-c/" title="Very short snippet: ottenere l&#8217;output di un URL in Objective-C (5 febbraio, 2010)">Very short snippet: ottenere l&#8217;output di un URL in Objective-C</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/11/21/very-short-snippet-apple-iphone-file-system/" title="Very short snippet: Apple iPhone file system (21 novembre, 2009)">Very short snippet: Apple iPhone file system</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/10/09/very-short-snippet-iphone-numeri-casuali/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe Flash Professional CS5 per Apple iPhone</title>
		<link>http://www.undolog.com/2009/10/07/adobe-flash-professiona-cs5-per-apple-iphone/</link>
		<comments>http://www.undolog.com/2009/10/07/adobe-flash-professiona-cs5-per-apple-iphone/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 08:16:54 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Eventi & Iniziative]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[Tecnologia]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Adobe Flash Professiona 5]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2522</guid>
		<description><![CDATA[

Adobe Professional CS5 - preview
Applicazioni iPhone





	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	



	Tags: Adobe, Adobe Flash Professiona 5, Apple, Eventi &#38; Iniziative, Flash, iPhone, Mobile, Sviluppo, Tecnologia

	Post correlati
	
	XCode: organizzare il codice con la direttiva #pragma mark (0)
	XCode: consigli sul Debugging Preferences (0)
	Xcode shortcut (0)
	Web2.0: Adobe ci prova con Apollo? (2)
	Very short trick: fermare NSTimer (0)


]]></description>
			<content:encoded><![CDATA[<p class="center"><img src="http://www.undolog.com/wp-content/uploads/2009/10/Immagine-2.png" alt="Adobe Flash Professiona 5 per Apple iPhone" title="Adobe Flash Professiona 5 per Apple iPhone" width="482" height="130" class="alignnone size-full wp-image-2521" /></p>
<ul>
<li><a href="http://labs.adobe.com/technologies/flashcs5/">Adobe Professional CS5 - preview</a></li>
<li><a href="http://labs.adobe.com/technologies/flashcs5/appsfor_iphone/">Applicazioni iPhone</a></li>
</ul>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;bodytext=%0D%0A%0D%0AAdobe%20Professional%20CS5%20-%20preview%0D%0AApplicazioni%20iPhone%0D%0A" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;notes=%0D%0A%0D%0AAdobe%20Professional%20CS5%20-%20preview%0D%0AApplicazioni%20iPhone%0D%0A" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;t=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;annotation=%0D%0A%0D%0AAdobe%20Professional%20CS5%20-%20preview%0D%0AApplicazioni%20iPhone%0D%0A" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;headline=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=%0D%0A%0D%0AAdobe%20Professional%20CS5%20-%20preview%0D%0AApplicazioni%20iPhone%0D%0A" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;t=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F&amp;title=Adobe%20Flash%20Professional%20CS5%20per%20Apple%20iPhone" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F10%2F07%2Fadobe-flash-professiona-cs5-per-apple-iphone%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/adobe/" title="Adobe" rel="tag">Adobe</a>, <a href="http://www.undolog.com/tag/adobe-flash-professiona-5/" title="Adobe Flash Professiona 5" rel="tag">Adobe Flash Professiona 5</a>, <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/category/eventi-iniziative/" title="Eventi &amp; Iniziative" rel="tag">Eventi &amp; Iniziative</a>, <a href="http://www.undolog.com/category/sviluppo/flash/" title="Flash" rel="tag">Flash</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/category/tecnologia/" title="Tecnologia" rel="tag">Tecnologia</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/20/xcode-consigli-sul-debugging-preferences/" title="XCode: consigli sul Debugging Preferences (20 luglio, 2009)">XCode: consigli sul Debugging Preferences</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2007/02/13/web20-adobe-ci-prova-con-apollo/" title="Web2.0: Adobe ci prova con Apollo? (13 febbraio, 2007)">Web2.0: Adobe ci prova con Apollo?</a> (2)</li>
	<li><a href="http://www.undolog.com/2009/06/16/very-short-trick-fermare-nstimer/" title="Very short trick: fermare NSTimer (16 giugno, 2009)">Very short trick: fermare NSTimer</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/10/07/adobe-flash-professiona-cs5-per-apple-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Come impostare XCode per usare l&#8217;iPhone al posto del simulatore</title>
		<link>http://www.undolog.com/2009/08/27/come-impostare-xcode-per-usare-liphone-al-posto-del-simulatore/</link>
		<comments>http://www.undolog.com/2009/08/27/come-impostare-xcode-per-usare-liphone-al-posto-del-simulatore/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 23:05:21 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Device]]></category>
		<category><![CDATA[Screencast]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2319</guid>
		<description><![CDATA[Uno screencast di sette minuti completo di ogni dettaglio]]></description>
			<content:encoded><![CDATA[<p class="center"><img src="http://www.undolog.com/wp-content/uploads/2009/08/imgartscreen.png" alt="Screencast" title="Screencast" width="595" height="193" /></p>
<p>In rete ho trovato un bellissimo <a target="_blank" href="http://www.mobileorchard.com/iphone-development-provisioning/"><strong>screencast</strong></a> su come configurare il nostro <em>device</em> <strong>iPhone</strong> in modo da poterlo utilizzare per il test di un'applicazione; al posto quindi del simulatore. Lo <a target="_blank" href="http://www.mobileorchard.com/iphone-development-provisioning/">screencast</a> dura circa sette minuti e ci guiderà passo per passo su tutto il processo di configurazione dell'ambiente XCode, la richiesta dei certificati, etc... così da poter lanciare il codice sorgente sul dispositivo <strong>iPhone</strong>. Contestualmente allo <a target="_blank" href="http://www.mobileorchard.com/iphone-development-provisioning/">screencast</a> potete avvalervi anche di una spiegazione testuale presente nel pacchetto.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;bodytext=Uno%20screencast%20di%20sette%20minuti%20completo%20di%20ogni%20dettaglio" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;notes=Uno%20screencast%20di%20sette%20minuti%20completo%20di%20ogni%20dettaglio" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;t=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;annotation=Uno%20screencast%20di%20sette%20minuti%20completo%20di%20ogni%20dettaglio" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;headline=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Uno%20screencast%20di%20sette%20minuti%20completo%20di%20ogni%20dettaglio" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;t=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F&amp;title=Come%20impostare%20XCode%20per%20usare%20l%27iPhone%20al%20posto%20del%20simulatore" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F08%2F27%2Fcome-impostare-xcode-per-usare-liphone-al-posto-del-simulatore%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/debug/" title="Debug" rel="tag">Debug</a>, <a href="http://www.undolog.com/tag/device/" title="Device" rel="tag">Device</a>, <a href="http://www.undolog.com/category/featured/" title="Featured" rel="tag">Featured</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/screencast/" title="Screencast" rel="tag">Screencast</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/category/tutorials/" title="Tutorials" rel="tag">Tutorials</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/07/20/xcode-consigli-sul-debugging-preferences/" title="XCode: consigli sul Debugging Preferences (20 luglio, 2009)">XCode: consigli sul Debugging Preferences</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/16/very-short-trick-fermare-nstimer/" title="Very short trick: fermare NSTimer (16 giugno, 2009)">Very short trick: fermare NSTimer</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/27/objective-c-unalternativa-alluso-di-cgrectmake/" title="Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake (27 luglio, 2009)">Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake</a> (2)</li>
	<li><a href="http://www.undolog.com/2009/06/29/iphone-tutti-i-font-di-sistema/" title="iPhone: tutti i font di sistema (29 giugno, 2009)">iPhone: tutti i font di sistema</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/08/27/come-impostare-xcode-per-usare-liphone-al-posto-del-simulatore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone: creare un metodo per rispondere agli eventi cross class</title>
		<link>http://www.undolog.com/2009/07/29/iphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class/</link>
		<comments>http://www.undolog.com/2009/07/29/iphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 22:00:26 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[self]]></category>
		<category><![CDATA[target]]></category>
		<category><![CDATA[UIApplicationDelegate]]></category>
		<category><![CDATA[UIViewController]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=1775</guid>
		<description><![CDATA[Normalmente un evento, che altro non è che un messaggio, viene risolto (impostato ed implementato) nella stessa classe o contesto, della funzione o procedura "chiamante". Ad esempio se aggiungiamo un bottone UIButton via codice (programmatically), possiamo trovarci all'interno di una nostra classe UIView o in un UIViewController. In entrambi i casi l'operazione di allocazione e [...]]]></description>
			<content:encoded><![CDATA[<p>Normalmente un evento, che altro non è che un messaggio, viene risolto (impostato ed implementato) nella stessa classe o contesto, della funzione o procedura "chiamante". Ad esempio se aggiungiamo un bottone <code>UIButton</code> via codice (programmatically), possiamo trovarci all'interno di una nostra classe <code>UIView</code> o in un <code>UIViewController</code>. In entrambi i casi l'operazione di allocazione e inizializzazione del bottone sarà seguita dall'impostazione del <code>target</code> che dovrà ricevere un messaggio quando si "cliccherà" sul bottone, sul tipo:</p>
<div class="igBar"><span id="lobjc-126"><a href="#" onclick="javascript:showCodeTxt('objc-126'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-126">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIButton <span style="color: #002200;">*</span>bottone <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIButton buttonWithType<span style="color: #002200;">:</span>UIButtonTypeRoundedRect<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">bottone.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>10, 180, 300, 30<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>bottone setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Press me&quot;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// decide chi deve ricevere il messaggio UIControlEventTouchUpInside</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>bottone addTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>onButtonClicked<span style="color: #002200;">&#41;</span> forControlEvents<span style="color: #002200;">:</span>UIControlEventTouchUpInside<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> onButtonClicked <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>La riga 5 del codice mostrato sopra decide chi (l'oggetto) e cosa (il metodo) "chiamare" quando il nostro bottone è stato premuto. Nell'esempio sopra illustrato si nota anche che l'impostazione del messaggio di pressione viene inviato al metodo <code>onButtonClick</code> implementato più sotto, quindi facente parte dello stesso contesto (o classe). La prima considerazione ovvia che possiamo fare, dunque, è che alterando i parametri <code>self</code> e <code>action</code> potremmo inviare il nostro messaggio ad un qualsiasi altro oggetto, posto quindi al difuori del contesto in uso. Ecco un esempio pratico: una classe <code>UIApplicationDelegate</code> crea un <code>UIViewController</code>:</p>
<div class="igBar"><span id="lobjc-127"><a href="#" onclick="javascript:showCodeTxt('objc-127'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-127">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// myAppDelegate.m</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">splashScreenController <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>SplashScreenController alloc<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>window addSubview<span style="color: #002200;">:</span>splashScreenController.view<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Lo <code>SplashScreenController</code> espone un metodo che permette di animare la <code>UIView</code> associata al <code>UIViewController</code> stesso:</p>
<div class="igBar"><span id="lobjc-128"><a href="#" onclick="javascript:showCodeTxt('objc-128'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-128">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// SplashScreenController.m</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> animateBackgroundDown <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>0.75<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationCurve<span style="color: #002200;">:</span>UIViewAnimationCurveEaseInOut<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationDelegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationDidStopSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>onAnimationFinished<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; self.view.frame <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>0,480,320,480<span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> onAnimationFinished <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Animazione terminata&quot;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Il codice sopra mostra un metodo definito all'interno della classe <code>SplashScreenController</code> di tipo <code>UIViewController</code>. Esso non fa altro che animare la <code>UIView</code> animandola verso il basso e, quando l'animazione è terminata, chiamare il metodo (invia un messaggio a se stesso - da qui <code>self</code>) <code>onAnimationFinished</code> definito più sotto, facente parte sempre della classe <code>SplashScreenController</code>. Ne segue che nella nostra <code>myAppDelegate</code>, quando invocheremo il metodo <code>animateBackgroundDown</code>, non saremo informati della fine dell'animazione:</p>
<div class="igBar"><span id="lobjc-129"><a href="#" onclick="javascript:showCodeTxt('objc-129'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-129">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// myAppDelegate.m</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>splashScreenController animateBackgroundDown<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Quello che potremmo desiderare, invece, è realizzare una nuova versione di <code>animateBackgroundDown</code> tale da dirgli <strong>a chi</strong> inviare il messaggio di fine animazione e <strong>quale metodo</strong> chiamare. In pratica vogliamo fare in modo di poter scrivere nella nostra classe <code>myAppDelegate</code>:</p>
<div class="igBar"><span id="lobjc-130"><a href="#" onclick="javascript:showCodeTxt('objc-130'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-130">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// myAppDelegate.m</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>splashScreenController animateBackgroundDown<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>onAnimationFinished<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// ...</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> onAnimationFinished <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Animazione terminata&quot;</span><span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Questa volta il metodo <code>onAnimationFinished</code> <strong>non si trova</strong> nel <code>UIViewController</code>, bensì in <code>myAppDelegate</code>. Per fare questo è sufficiente modificare il metodo <code>animateBackgroundDown</code> nel <code>UIViewController</code> nel modo seguente:</p>
<div class="igBar"><span id="lobjc-131"><a href="#" onclick="javascript:showCodeTxt('objc-131'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-131">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">// SplashScreenController.m</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> animateBackgroundDown<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>0.75<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationCurve<span style="color: #002200;">:</span>UIViewAnimationCurveEaseInOut<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationDelegate<span style="color: #002200;">:</span>target<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView setAnimationDidStopSelector<span style="color: #002200;">:</span>selector<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; self.view.frame <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>0,480,320,480<span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Adesso abbiamo un metodo che <strong>accetta il "contesto"</strong> (<code>target</code>) e <strong>il metodo</strong> da chiamare (<code>selector</code>). Adesso, quando l'animazione termina, il messaggio <code>AnimationDidStop</code> sarà inviato a <code>myAppDelegate</code> a qualsiasi altro "oggetto" / classe in grado di riceverlo.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;bodytext=Normalmente%20un%20evento%2C%20che%20altro%20non%20%C3%A8%20che%20un%20messaggio%2C%20viene%20risolto%20%28impostato%20ed%20implementato%29%20nella%20stessa%20classe%20o%20contesto%2C%20della%20funzione%20o%20procedura%20%22chiamante%22.%20Ad%20esempio%20se%20aggiungiamo%20un%20bottone%20UIButton%20via%20codice%20%28programmatically%29%2C%20p" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;notes=Normalmente%20un%20evento%2C%20che%20altro%20non%20%C3%A8%20che%20un%20messaggio%2C%20viene%20risolto%20%28impostato%20ed%20implementato%29%20nella%20stessa%20classe%20o%20contesto%2C%20della%20funzione%20o%20procedura%20%22chiamante%22.%20Ad%20esempio%20se%20aggiungiamo%20un%20bottone%20UIButton%20via%20codice%20%28programmatically%29%2C%20p" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;t=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;annotation=Normalmente%20un%20evento%2C%20che%20altro%20non%20%C3%A8%20che%20un%20messaggio%2C%20viene%20risolto%20%28impostato%20ed%20implementato%29%20nella%20stessa%20classe%20o%20contesto%2C%20della%20funzione%20o%20procedura%20%22chiamante%22.%20Ad%20esempio%20se%20aggiungiamo%20un%20bottone%20UIButton%20via%20codice%20%28programmatically%29%2C%20p" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;headline=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=Normalmente%20un%20evento%2C%20che%20altro%20non%20%C3%A8%20che%20un%20messaggio%2C%20viene%20risolto%20%28impostato%20ed%20implementato%29%20nella%20stessa%20classe%20o%20contesto%2C%20della%20funzione%20o%20procedura%20%22chiamante%22.%20Ad%20esempio%20se%20aggiungiamo%20un%20bottone%20UIButton%20via%20codice%20%28programmatically%29%2C%20p" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;t=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F&amp;title=iPhone%3A%20creare%20un%20metodo%20per%20rispondere%20agli%20eventi%20cross%20class" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F29%2Fiphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/callback/" title="callback" rel="tag">callback</a>, <a href="http://www.undolog.com/tag/events/" title="events" rel="tag">events</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/tag/message/" title="message" rel="tag">message</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/selector/" title="selector" rel="tag">selector</a>, <a href="http://www.undolog.com/tag/self/" title="self" rel="tag">self</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/target/" title="target" rel="tag">target</a>, <a href="http://www.undolog.com/tag/uiapplicationdelegate/" title="UIApplicationDelegate" rel="tag">UIApplicationDelegate</a>, <a href="http://www.undolog.com/tag/uiviewcontroller/" title="UIViewController" rel="tag">UIViewController</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2010/02/10/come-creare-un-proprio-protocollo-con-delegato/" title="Come creare un proprio protocollo con delegato (10 febbraio, 2010)">Come creare un proprio protocollo con delegato</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/13/iphone-secondapp-indovina-il-numero-parte-2/" title="iPhone SecondApp: indovina il numero &#8211; parte 2 (13 luglio, 2009)">iPhone SecondApp: indovina il numero &#8211; parte 2</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/10/xcode-organizzare-il-codice-con-la-direttiva-pragma-mark/" title="XCode: organizzare il codice con la direttiva #pragma mark (10 luglio, 2009)">XCode: organizzare il codice con la direttiva #pragma mark</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/16/very-short-trick-fermare-nstimer/" title="Very short trick: fermare NSTimer (16 giugno, 2009)">Very short trick: fermare NSTimer</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/07/29/iphone-creare-un-metodo-per-rispondere-agli-eventi-cross-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C: un&#8217;alternativa all&#8217;uso di CGRectMake</title>
		<link>http://www.undolog.com/2009/07/27/objective-c-unalternativa-alluso-di-cgrectmake/</link>
		<comments>http://www.undolog.com/2009/07/27/objective-c-unalternativa-alluso-di-cgrectmake/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 06:00:55 +0000</pubDate>
		<dc:creator>Giovambattista Fazioli</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[CGFloat]]></category>
		<category><![CDATA[CGPoint]]></category>
		<category><![CDATA[CGRect]]></category>
		<category><![CDATA[CGRectMake]]></category>
		<category><![CDATA[CGSize]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[struct]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.undolog.com/?p=2234</guid>
		<description><![CDATA[CGRectMake() è una funzione (in realtà è un inline #define) molto usata soprattutto quando si creano da codice oggetti grafici o di interfaccia utente. Il suo utilizzo è quindi spesso legato all'inizializzazione di componenti UIKit, ma anche a semplici UIView o UIImageView. CGRectMake() restituisce una struct (struttura di tipo) CGRect:
PLAIN TEXT
Objective-C:




struct CGRect &#123;


&#160; CGPoint origin;


&#160; [...]]]></description>
			<content:encoded><![CDATA[<p><code>CGRectMake()</code> è una funzione (in realtà è un inline #define) molto usata soprattutto quando si creano da codice oggetti grafici o di interfaccia utente. Il suo utilizzo è quindi spesso legato all'inizializzazione di componenti <code>UIKit</code>, ma anche a semplici <code>UIView</code> o <code>UIImageView</code>. <code>CGRectMake()</code> restituisce una <code>struct</code> (struttura di tipo) <code>CGRect</code>:</p>
<div class="igBar"><span id="lobjc-137"><a href="#" onclick="javascript:showCodeTxt('objc-137'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-137">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">struct</span> CGRect <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; CGPoint origin;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; CGSize size;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">typedef</span> <span style="color: #a61390;">struct</span> CGRect CGRect;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Che a sua volta è composta da due diverse struct <code>CGPoint</code> e <code>CGSize</code>:</p>
<div class="igBar"><span id="lobjc-138"><a href="#" onclick="javascript:showCodeTxt('objc-138'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-138">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">struct</span> CGPoint <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; CGFloat x;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; CGFloat y;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">typedef</span> <span style="color: #a61390;">struct</span> CGPoint CGPoint;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #11740a; font-style: italic;">/* Sizes. */</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">struct</span> CGSize <span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; CGFloat width;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; CGFloat height;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a61390;">typedef</span> <span style="color: #a61390;">struct</span> CGSize CGSize;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Che, a loro volta ancora, contengono tipi <code>CGFloat</code>, ovvero tipi <code>float</code>. Se andiamo ad analizzare il codice della CGRectMake() troviamo:</p>
<div class="igBar"><span id="lobjc-139"><a href="#" onclick="javascript:showCodeTxt('objc-139'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-139">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CG_INLINE CGRect</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">CGRectMake<span style="color: #002200;">&#40;</span>CGFloat x, CGFloat y, CGFloat width, CGFloat height<span style="color: #002200;">&#41;</span></div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#123;</span></div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; CGRect rect;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; rect.origin.x <span style="color: #002200;">=</span> x; rect.origin.y <span style="color: #002200;">=</span> y;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; rect.size.width <span style="color: #002200;">=</span> width; rect.size.height <span style="color: #002200;">=</span> height;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; <span style="color: #a61390;">return</span> rect;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ne deriva, quindi, che questa parte di codice:</p>
<div class="igBar"><span id="lobjc-140"><a href="#" onclick="javascript:showCodeTxt('objc-140'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-140">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIButton <span style="color: #002200;">*</span>gbutton <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIButton buttonWithType<span style="color: #002200;">:</span>UIButtonTypeRoundedRect<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">gbutton.frame <span style="color: #002200;">=</span> CGRectMake <span style="color: #002200;">&#40;</span>12,409,100,40<span style="color: #002200;">&#41;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>gbutton setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Press&quot;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>mainWindow addSubview<span style="color: #002200;">:</span>gbutton<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Potrebbe, a ragione, essere scritta anche come:</p>
<div class="igBar"><span id="lobjc-141"><a href="#" onclick="javascript:showCodeTxt('objc-141'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Objective-C:</span>
<div id="objc-141">
<div class="objc" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UIButton <span style="color: #002200;">*</span>gbutton <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIButton buttonWithType<span style="color: #002200;">:</span>UIButtonTypeRoundedRect<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">gbutton.frame <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>12,409,100,40<span style="color: #002200;">&#125;</span>;</div>
</li>
<li style="font-weight: normal; vertical-align:top;color:#758DB8;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>gbutton setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Press&quot;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;</div>
</li>
<li style="font-weight: bold; vertical-align:top;color:#FF9900;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #002200;">&#91;</span>mainWindow addSubview<span style="color: #002200;">:</span>gbutton<span style="color: #002200;">&#93;</span>;</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Giusto per velocizzare un po' l'esecuzione del codice... <img src='http://www.undolog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;bodytext=CGRectMake%28%29%20%C3%A8%20una%20funzione%20%28in%20realt%C3%A0%20%C3%A8%20un%20inline%20%23define%29%20molto%20usata%20soprattutto%20quando%20si%20creano%20da%20codice%20oggetti%20grafici%20o%20di%20interfaccia%20utente.%20Il%20suo%20utilizzo%20%C3%A8%20quindi%20spesso%20legato%20all%27inizializzazione%20di%20componenti%20UIKit%2C%20ma%20anche%20a%20se" title="Digg"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;notes=CGRectMake%28%29%20%C3%A8%20una%20funzione%20%28in%20realt%C3%A0%20%C3%A8%20un%20inline%20%23define%29%20molto%20usata%20soprattutto%20quando%20si%20creano%20da%20codice%20oggetti%20grafici%20o%20di%20interfaccia%20utente.%20Il%20suo%20utilizzo%20%C3%A8%20quindi%20spesso%20legato%20all%27inizializzazione%20di%20componenti%20UIKit%2C%20ma%20anche%20a%20se" title="del.icio.us"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F" title="Technorati"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;t=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake" title="Facebook"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;annotation=CGRectMake%28%29%20%C3%A8%20una%20funzione%20%28in%20realt%C3%A0%20%C3%A8%20un%20inline%20%23define%29%20molto%20usata%20soprattutto%20quando%20si%20creano%20da%20codice%20oggetti%20grafici%20o%20di%20interfaccia%20utente.%20Il%20suo%20utilizzo%20%C3%A8%20quindi%20spesso%20legato%20all%27inizializzazione%20di%20componenti%20UIKit%2C%20ma%20anche%20a%20se" title="Google Bookmarks"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake%20-%20http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F" title="Twitter"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://barrapunto.com/submit.pl?subj=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;story=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F" title="BarraPunto"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/barrapunto.png" title="BarraPunto" alt="BarraPunto" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://current.com/clipper.htm?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake" title="Current"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;body=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F" title="email"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;link=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F" title="FriendFeed"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://laaik.it/NewStoryCompact.aspx?uri=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;headline=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;cat=5e082fcc-8a3b-47e2-acec-fdf64ff19d12" title="laaik.it"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/laaikit.png" title="laaik.it" alt="laaik.it" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;source=Undolog.com+Research+%26amp%3B+Development++Blog&amp;summary=CGRectMake%28%29%20%C3%A8%20una%20funzione%20%28in%20realt%C3%A0%20%C3%A8%20un%20inline%20%23define%29%20molto%20usata%20soprattutto%20quando%20si%20creano%20da%20codice%20oggetti%20grafici%20o%20di%20interfaccia%20utente.%20Il%20suo%20utilizzo%20%C3%A8%20quindi%20spesso%20legato%20all%27inizializzazione%20di%20componenti%20UIKit%2C%20ma%20anche%20a%20se" title="LinkedIn"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake" title="Live"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;t=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake" title="MySpace"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake&amp;url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F" title="Netvibes"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;partner=sociable" title="Print"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.undolog.com/feed/" title="RSS"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://segnalo.alice.it/post.html.php?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake" title="Segnalo"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/segnalo.png" title="Segnalo" alt="Segnalo" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F&amp;title=Objective-C%3A%20un%27alternativa%20all%27uso%20di%20CGRectMake" title="StumbleUpon"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.wikio.it/vote?url=http%3A%2F%2Fwww.undolog.com%2F2009%2F07%2F27%2Fobjective-c-unalternativa-alluso-di-cgrectmake%2F" title="Wikio IT"><img src="http://www.undolog.com/wp-content/plugins/sociable/images/wikio.png" title="Wikio IT" alt="Wikio IT" class="sociable-hovers" /></a>


<br/><br/>
	Tags: <a href="http://www.undolog.com/tag/apple/" title="Apple" rel="tag">Apple</a>, <a href="http://www.undolog.com/tag/cgfloat/" title="CGFloat" rel="tag">CGFloat</a>, <a href="http://www.undolog.com/tag/cgpoint/" title="CGPoint" rel="tag">CGPoint</a>, <a href="http://www.undolog.com/tag/cgrect/" title="CGRect" rel="tag">CGRect</a>, <a href="http://www.undolog.com/tag/cgrectmake/" title="CGRectMake" rel="tag">CGRectMake</a>, <a href="http://www.undolog.com/tag/cgsize/" title="CGSize" rel="tag">CGSize</a>, <a href="http://www.undolog.com/tag/float/" title="float" rel="tag">float</a>, <a href="http://www.undolog.com/tag/iphone/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/" title="iPhone" rel="tag">iPhone</a>, <a href="http://www.undolog.com/category/mobile/" title="Mobile" rel="tag">Mobile</a>, <a href="http://www.undolog.com/tag/objective-c/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/category/sviluppo/iphone-sviluppo/objective-c-sviluppo/" title="Objective-C" rel="tag">Objective-C</a>, <a href="http://www.undolog.com/tag/struct/" title="struct" rel="tag">struct</a>, <a href="http://www.undolog.com/category/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/sviluppo/" title="Sviluppo" rel="tag">Sviluppo</a>, <a href="http://www.undolog.com/tag/xcode/" title="XCode" rel="tag">XCode</a><br />

	<h4>Post correlati</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.undolog.com/2009/10/29/objective-c-nslog-su-struct-c/" title="Objective-C: NSLog() su struct C (29 ottobre, 2009)">Objective-C: NSLog() su struct C</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/23/xcode-shortcut/" title="Xcode shortcut (23 luglio, 2009)">Xcode shortcut</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/29/iphone-tutti-i-font-di-sistema/" title="iPhone: tutti i font di sistema (29 giugno, 2009)">iPhone: tutti i font di sistema</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/07/13/iphone-secondapp-indovina-il-numero-parte-2/" title="iPhone SecondApp: indovina il numero &#8211; parte 2 (13 luglio, 2009)">iPhone SecondApp: indovina il numero &#8211; parte 2</a> (0)</li>
	<li><a href="http://www.undolog.com/2009/06/23/iphone-firstapp-indovina-il-numero-parte-1/" title="iPhone FirstApp: indovina il numero &#8211; parte 1 (23 giugno, 2009)">iPhone FirstApp: indovina il numero &#8211; parte 1</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.undolog.com/2009/07/27/objective-c-unalternativa-alluso-di-cgrectmake/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
