<?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>Massimo Oliviero &#187; Programmazione</title>
	<atom:link href="http://www.massimooliviero.net/categoria/programmazione/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.massimooliviero.net</link>
	<description>I deliri digitali di un programmatore informatico e aspirante musicista...</description>
	<lastBuildDate>Tue, 24 Jan 2012 13:41:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Chrome, 3 estensioni in per chi lavora con REST e JSON</title>
		<link>http://www.massimooliviero.net/2011/12/22/chrome-3-estensioni-in-per-chi-lavora-con-rest-e-json/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=chrome-3-estensioni-in-per-chi-lavora-con-rest-e-json</link>
		<comments>http://www.massimooliviero.net/2011/12/22/chrome-3-estensioni-in-per-chi-lavora-con-rest-e-json/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 06:47:41 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Extensions]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=1027</guid>
		<description><![CDATA[Lentamente lo store il Chrome web store si sta popolando di estensioni interessanti e funzionali. In particolare per chi lavora pesantemente con servizi REST segnalo questi 3 strumenti: JSONView Advanced REST client Application REST Console Must have]]></description>
			<content:encoded><![CDATA[<p>Lentamente lo store il <a href="ps://chrome.google.com/webstore/">Chrome web store </a>si sta popolando di estensioni interessanti e funzionali. In particolare per chi lavora pesantemente con servizi REST segnalo questi 3 strumenti:</p>
<ol>
<li><a href="https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc">JSONView</a></li>
<li><a href="https://chrome.google.com/webstore/detail/hgmloofddffdnphfgcellkdfbfbjeloo">Advanced REST client Application</a></li>
<li><a href="https://chrome.google.com/webstore/detail/cokgbflfommojglbmbpenpphppikmonn">REST Console</a></li>
</ol>
<p>Must have <img src='http://www.massimooliviero.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/12/22/chrome-3-estensioni-in-per-chi-lavora-con-rest-e-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perché XCode 4 è così lento?</title>
		<link>http://www.massimooliviero.net/2011/12/21/perche-xcode-4-e-cosi-lento/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=perche-xcode-4-e-cosi-lento</link>
		<comments>http://www.massimooliviero.net/2011/12/21/perche-xcode-4-e-cosi-lento/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 11:00:25 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[iLesson]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[iOS5]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=1021</guid>
		<description><![CDATA[Già perché? Perché fa schifo, semplice. La dimostrazione è la quantità spropositata di forum e messaggi di aiuto che circolano in rete. In particolare XCode 4.2 è flemmatico e ottuso. Purtroppo la storia di questo IDE è costellata da tutta una serie di bug incredibili, di feature mancanti e addirittura di funzionalità rimosse senza spiegazione! Una [...]]]></description>
			<content:encoded><![CDATA[<p>Già perché? Perché <strong><em>fa schifo</em></strong>, semplice. La dimostrazione è la quantità spropositata di forum e messaggi di aiuto che circolano in rete. In particolare <strong><em>XCode 4.2</em></strong> è flemmatico e ottuso. Purtroppo la storia di questo <strong><em>IDE</em></strong> è costellata da tutta una serie di <strong><em>bug</em></strong> incredibili, di <strong><em>feature</em></strong> mancanti e addirittura di <a href="http://stackoverflow.com/questions/6568817/how-to-create-an-interface-builder-plugin-in-xcode4">funzionalità rimosse</a> senza spiegazione!</p>
<p>Una approccio ingiustificato da parte di <strong><em>Apple</em></strong> che nonostante tutto continua a trincerarsi dietro un silenzio assordante. Un pratica che io non comprendo e che aborro dal profondo. Questa incuria dei suoi <strong><em>developer</em></strong> che nonostante tutto sono di gran lunga i più fanatici sul globo. Una pratica che permea l&#8217;azienda di Cupertino fin dalle origini e che non accenna a diradarsi. L&#8217;uscita di <strong><em>iOS5</em></strong> e <strong><em>XCode 4.2</em></strong> ne è l&#8217;esempio lapalissiano.</p>
<p>Su questi aspetti avrò modo di ritornarci nei successivi post. Dicevamo <em>XCode</em> lento, che fare? Non molto purtroppo, a parte i soliti consigli da mentecatti come &#8220;<em>compra più RAM</em>&#8221; o &#8220;<em>cambia mac</em>&#8221; gli unici che mi sento di suggerire veramente sono:</p>
<ol>
<li><a href="http://stackoverflow.com/questions/5410191/hidden-features-of-xcode-4/7925816#7925816">Limitare il numero di cocurrent build operation</a></li>
<li><a href="http://stackoverflow.com/questions/5410191/hidden-features-of-xcode-4/7925816#7925816">Disabilitare l&#8217;indexing del codice</a></li>
</ol>
<p>Come si dice &#8220;di più ninzò&#8221; <img src='http://www.massimooliviero.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Qualche fonte:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/5410191/hidden-features-of-xcode-4">http://stackoverflow.com/questions/5410191/hidden-features-of-xcode-4</a></li>
<li><a href="http://developer.apple.com/library/ios/#releasenotes/DeveloperTools/RN-Xcode/_index.html">http://developer.apple.com/library/ios/#releasenotes/DeveloperTools/RN-Xcode/_index.html</a></li>
<li><a href="http://stackoverflow.com/questions/7780663/why-are-xcodebuild-and-xcode-4-2-so-slow">http://stackoverflow.com/questions/7780663/why-are-xcodebuild-and-xcode-4-2-so-slow</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/12/21/perche-xcode-4-e-cosi-lento/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Networking framework per iOS e Mac OS X</title>
		<link>http://www.massimooliviero.net/2011/12/13/networking-framework-per-ios-e-mac-os-x/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=networking-framework-per-ios-e-mac-os-x</link>
		<comments>http://www.massimooliviero.net/2011/12/13/networking-framework-per-ios-e-mac-os-x/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 21:54:00 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[ASIHTTPRequest]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[NSURLConnection]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=1008</guid>
		<description><![CDATA[ASIHTTPrequest, per chi ancora non lo conoscesse, è uno dei migliori framework per gestire connessioni http con iOS e Mac OS. E&#8217; diventato il mio framework di riferimento per tutti i progetti che richiedono una comunicazione client/server, tipicamente con servizi REST. ASIHTTPRequest porta con se una ricca dote di funzionalità e semplificazioni non indifferenti, soprattutto [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://allseeing-i.com/ASIHTTPRequest/">ASIHTTPrequest</a>, per chi ancora non lo conoscesse, è uno dei migliori framework per gestire connessioni http con <em>iOS </em>e<em> Mac OS</em>. E&#8217; diventato il mio framework di riferimento per tutti i progetti che richiedono una comunicazione client/server, tipicamente con servizi REST. ASIHTTPRequest porta con se una ricca dote di funzionalità e semplificazioni non indifferenti, soprattutto se paragonato al blando e scarno <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html">NSURLConnection</a>.</p>
<p>Ultimamente sto valutando delle alternative più leggere e moderne. Dopo qualche ricerca mi sono imbattuto in due framework interessanti:</p>
<ol>
<li><a href="https://github.com/AFNetworking/AFNetworking">AFNetworking &#8211; A delightful iOS and OS X networking framework</a></li>
<li><a href="https://github.com/MugunthKumar/MKNetworkKit/tree/master/MKNetworkKit">MKNetworkKit - Full ARC based Networking Kit for iOS 4+ devices</a></li>
</ol>
<p>Sicuramente da valutare.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/12/13/networking-framework-per-ios-e-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS, bloccare lo scrolling di una UIWebView</title>
		<link>http://www.massimooliviero.net/2011/11/17/ios-bloccare-lo-scrolling-di-una-uiwebview/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ios-bloccare-lo-scrolling-di-una-uiwebview</link>
		<comments>http://www.massimooliviero.net/2011/11/17/ios-bloccare-lo-scrolling-di-una-uiwebview/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 14:02:18 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[iOS tips&tricks]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iOS4]]></category>
		<category><![CDATA[iOS5]]></category>
		<category><![CDATA[Scrolling]]></category>
		<category><![CDATA[UIWebView]]></category>
		<category><![CDATA[web view]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=990</guid>
		<description><![CDATA[Ecco un piccolo tip per bloccare lo scrolling di una web view in iOS 4.x. Infatti in tutte le versione dell&#8217;SDK fino alla 4.3.5 la UIScrollView presente all&#8217;interno della UIWebView non è esposta esternamente. Per poterla modificare è necessario cercarla all&#8217;interno delle subviews della web view. for &#40;id subview in self.webView.subviews&#41; &#123; if &#40;&#91;&#91;subview class&#93; isSubclassOfClass: [...]]]></description>
			<content:encoded><![CDATA[<p>Ecco un piccolo tip per bloccare lo <strong><em>scrolling</em></strong> di una <strong><em>web view</em></strong> in<strong><em> iOS 4.x</em></strong>. Infatti in tutte le versione dell&#8217;<strong><em>SDK</em></strong> fino alla 4.3.5 la <strong><em>UIScrollView</em></strong> presente all&#8217;interno della <strong><em>UIWebView</em></strong> non è esposta esternamente. Per poterla modificare è necessario cercarla all&#8217;interno delle subviews della <em>web view</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span> subview <span style="color: #a61390;">in</span> self.webView.subviews<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>   
   <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>subview class<span style="color: #002200;">&#93;</span> isSubclassOfClass<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span>UIScrollView class<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>   
   <span style="color: #002200;">&#123;</span>       
      <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>UIScrollView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>subview<span style="color: #002200;">&#41;</span>.scrollEnabled <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;       
      <span style="color: #a61390;">break</span>;   
   <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// oppure così (anche se è meno sicuro perché non è certo</span>
<span style="color: #11740a; font-style: italic;">// che la scroll view si trovi sempre nella prima posizione)</span>
<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>webView.subviews objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span> setScrollEnabled<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>E con<em><strong> iOS 5</strong></em>? beh le cose si semplificano di un pelo&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">self.webView.scrollView.scrollEnabled <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;</pre></div></div>

<p>o no? <img src='http://www.massimooliviero.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/11/17/ios-bloccare-lo-scrolling-di-una-uiwebview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac OSX, abilitare l&#8217;auto completamento e i colori di Git</title>
		<link>http://www.massimooliviero.net/2011/11/16/mac-osx-abilitare-lauto-completamento-e-i-colori-di-git/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mac-osx-abilitare-lauto-completamento-e-i-colori-di-git</link>
		<comments>http://www.massimooliviero.net/2011/11/16/mac-osx-abilitare-lauto-completamento-e-i-colori-di-git/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 21:20:51 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[MacOSX tips&tricks]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=971</guid>
		<description><![CDATA[Utilizzo quotidianamente git da molti mesi e fin dall&#8217;inizio ho sentito l&#8217;esigenza di migliorare l&#8217;esperienza d&#8217;uso di questo strumento. Quello che non tutti sanno è che la versione installata su Mac OSX è configurata in modo essenziale  e questo vuol dire che: non ci sono colori nel comando status non c&#8217;è l&#8217;auto completamento dei comandi di [...]]]></description>
			<content:encoded><![CDATA[<p>Utilizzo quotidianamente <em><strong><a href="http://git-scm.com/">git</a></strong></em> da molti mesi e fin dall&#8217;inizio ho sentito l&#8217;esigenza di migliorare l&#8217;esperienza d&#8217;uso di questo strumento. Quello che non tutti sanno è che la versione installata su Mac OSX è configurata in modo essenziale  e questo vuol dire che:</p>
<ol>
<li>non ci sono colori nel comando status</li>
<li>non c&#8217;è l&#8217;auto completamento dei comandi di git</li>
<li>non ci sono nel prompt delle indicazioni sul branch in uso</li>
</ol>
<div>In pratica se entriamo in un progetto e digitiamo<em><strong> git status</strong></em> quello che otteniamo è una listato uniforme e molto confuso (figura 1)</div>
<div><a href="http://www.massimooliviero.net/wp-content/uploads/2011/11/mac_shell_nothing.png"><img class="size-full wp-image-972 aligncenter" style="margin-top: 10px; margin-bottom: 10px;" title="mac_shell_nothing" src="http://www.massimooliviero.net/wp-content/uploads/2011/11/mac_shell_nothing.png" alt="" width="532" height="434" /></a></div>
<div>Andiamo con ordine. Per prima cosa abilitiamo i colori di <strong><em>git</em></strong> con questo semplice comando:</div>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> config color.ui <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<div>Se ora digitiamo il comando<strong><em> git status</em></strong> otteniamo</div>
<div><a href="http://www.massimooliviero.net/wp-content/uploads/2011/11/mac_shell_git_status_color.png"><img class="size-full wp-image-976 aligncenter" style="margin-top: 10px; margin-bottom: 10px;" title="mac_shell_git_status_color" src="http://www.massimooliviero.net/wp-content/uploads/2011/11/mac_shell_git_status_color.png" alt="" width="532" height="234" /></a></div>
<div>Decisamente meglio. Next step: attivare l&#8217;auto completamento dei comandi git. Per farlo è necessario scaricare i file che servono dal repository ufficiale in questo modo:</div>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>tmp <span style="color: #666666; font-style: italic;"># se non esiste già</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
$ <span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>git.kernel.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>scm<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>git.git
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #c20cb9; font-weight: bold;">git</span>
$ <span style="color: #c20cb9; font-weight: bold;">git</span> checkout v<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #660033;">--version</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3}'</span><span style="color: #000000; font-weight: bold;">`</span>
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> contrib<span style="color: #000000; font-weight: bold;">/</span>completion<span style="color: #000000; font-weight: bold;">/</span>git-completion.bash ~<span style="color: #000000; font-weight: bold;">/</span>.git-completion.bash
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~
$ <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">git</span>
$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;&gt;&gt; .profile</span></pre></div></div>

<div>In particolare quest&#8217;ultimo comando creerà il file .profile nello home directory dell&#8217;utente se non esiste. Se tutto è andato a buon fine l&#8217;auto complemtamento dei comandi git dovrebbe essere attivo. Quindi digitando per esempio:</div>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>tab<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<div>Il comando dovrebbe auto-completarsi. Andiamo oltre, attiviamo anche la visualizzazione sul <strong><em>prompt</em></strong> dei comandi il nome del <strong><em>branch</em></strong> attivo e il suo stato. Per farlo basta modificare il file <strong><em>.profile</em></strong>, sulla home directory dell&#8217;utente, e aggiungere il seguente codice:</div>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">GIT_PS1_SHOWDIRTYSTATE</span>=<span style="color: #c20cb9; font-weight: bold;">true</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>bash_completion <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    . <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>bash_completion
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">'\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '</span></pre></div></div>

<div>Già che ci siamo diamo anche un tocco di colore alla shell in generale aggiungendo due righe in testa al file (se non sono già presenti):</div>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">CLICOLOR</span>=<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LSCOLORS</span>=GxFxCxDxBxegedabagaced</pre></div></div>

<div>Riavviamo il Terminale, entriamo in un progetto git e digitiamo git status quello che otteniamo è mostrato nella figura seguente.</div>
<div><a href="http://www.massimooliviero.net/wp-content/uploads/2011/11/mac_shell_git_status_power.png"><img class="aligncenter size-full wp-image-981" title="mac_shell_git_status_power" src="http://www.massimooliviero.net/wp-content/uploads/2011/11/mac_shell_git_status_power.png" alt="" width="635" height="273" /></a></div>
<div>Beh che dire, tutta un&#8217;altra storia!!! <img src='http://www.massimooliviero.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </div>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/11/16/mac-osx-abilitare-lauto-completamento-e-i-colori-di-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS, personalizzare la funzione NSLog</title>
		<link>http://www.massimooliviero.net/2011/10/10/ios-personalizzare-la-funzione-nslog/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ios-personalizzare-la-funzione-nslog</link>
		<comments>http://www.massimooliviero.net/2011/10/10/ios-personalizzare-la-funzione-nslog/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 20:22:06 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[iOS tips&tricks]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[NSLog]]></category>
		<category><![CDATA[obje]]></category>
		<category><![CDATA[objectivec]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=944</guid>
		<description><![CDATA[La funzione NSLog presente nel Foundation Kit è molto comoda in fase di debug di un&#8217;applicazione. NSLog non fa altro che stampare a console la stringa passata come argomento. Possiamo rendere NSLog &#8220;parlante&#8221; aggiungendo delle informazioni interessanti, come il nome del metodo e il numero di linea, ogni volta che viene chiamata. Per farlo è [...]]]></description>
			<content:encoded><![CDATA[<p>La funzione NSLog presente nel Foundation Kit è molto comoda in fase di debug di un&#8217;applicazione. NSLog non fa altro che stampare a console la stringa passata come argomento. Possiamo rendere NSLog &#8220;parlante&#8221; aggiungendo delle informazioni interessanti, come il nome del metodo e il numero di linea, ogni volta che viene chiamata.</p>
<p>Per farlo è necessario definire una propria funzione &#8220;MYLog&#8221; in un header comune o nel file .pch in questo modo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;"># define MYLog(fmt, ...) NSLog((@&quot;%s [Line %d] &quot; fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);</span></pre></td></tr></table></div>

<p><em><a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html">__PRETTY_FUNCTION__</a></em> e <em><a href="http://developer.apple.com/library/mac/#documentation/DeveloperTools/gcc-4.0.1/cpp/Standard-Predefined-Macros.html">__LINE__</a></em> sono due macro che hanno proprio lo scopo di visualizzare il nome del metodo e la linea. Ci sono anche altre macro che si posso utilizzare ad ognuno la sua scelta.</p>
<p>Se invece vogliamo fare in modo che queste informazioni siano stampate solo in DEBUG basta aggiungere un if in questo modo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#ifdef DEBUG</span>
<span style="color: #6e371a;">#   define MYLog(fmt, ...) NSLog((@&quot;%s [Line %d] &quot; fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);</span>
<span style="color: #6e371a;">#else</span>
<span style="color: #6e371a;">#   define MYLog(...)</span>
<span style="color: #6e371a;">#endif</span></pre></td></tr></table></div>

<p>Niente di più semplice e funzionale.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/10/10/ios-personalizzare-la-funzione-nslog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcode, Error starting executable, error launching remote program: failed to get the task for process</title>
		<link>http://www.massimooliviero.net/2011/08/12/xcode-error-starting-executable-error-launching-remote-program-failed-to-get-the-task-for-process/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=xcode-error-starting-executable-error-launching-remote-program-failed-to-get-the-task-for-process</link>
		<comments>http://www.massimooliviero.net/2011/08/12/xcode-error-starting-executable-error-launching-remote-program-failed-to-get-the-task-for-process/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 06:16:24 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[iOS tips&tricks]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Certificati]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[Deploy]]></category>
		<category><![CDATA[Distribution]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=888</guid>
		<description><![CDATA[Ecco cosa succede se si utilizza il certificato di distribuzione per fare il deploy in debug sul proprio device (ved Fig. 1): Error Starting Executable &#8216;program&#8217; Error launching remote program: failed to get the tast for process xxx &#160; &#160; La soluzione è molto semplice e consiste nel specificare un certificato sviluppatore per la configurazione [...]]]></description>
			<content:encoded><![CDATA[<p>Ecco cosa succede se si utilizza il certificato di distribuzione per fare il <em>deploy</em> in <em>debug</em> sul proprio <em>device</em> (ved Fig. 1):</p>
<blockquote><p><span style="color: #ff0000;">Error Starting Executable &#8216;program&#8217;</span><br />
<span style="color: #ff0000;">Error launching remote program: failed to get the tast for process xxx</span></p></blockquote>
<p>&nbsp;</p>
<div id="attachment_893" class="wp-caption aligncenter" style="width: 430px"><a href="http://www.massimooliviero.net/wp-content/uploads/2011/08/xcode_error_task.png"><img class="size-full wp-image-893" style="border-width: 1px; border-color: black; border-style: solid;" title="xcode_error_task" src="http://www.massimooliviero.net/wp-content/uploads/2011/08/xcode_error_task.png" alt="" width="420" height="152" /></a><p class="wp-caption-text">Figura 1 - XCode error</p></div>
<p>&nbsp;</p>
<p>La soluzione è molto semplice e consiste nel specificare un certificato sviluppatore per la configurazione <strong><em>debug</em></strong>. Per fare questo è sufficiente modificare il <em><strong>target</strong></em> utilizzato alla voce <em><strong>Code Signing </strong></em>parametro <strong></strong><em><strong>Code Signing Identity, </strong></em> sotto la voce <strong><em>Debug</em></strong> e <em><strong>Any iOS SDK</strong></em> specificare un certificato diverso da <em><strong>iPhone Distribution</strong></em> (Fig. 2).</p>
<p style="text-align: center;"><a href="http://www.massimooliviero.net/wp-content/uploads/2011/08/xcode_debug_certificate.png"><img class="aligncenter size-full wp-image-900" style="border-width: 1px; border-color: black; border-style: solid;" title="xcode_debug_identity" src="http://www.massimooliviero.net/wp-content/uploads/2011/08/xcode_debug_certificate.png" alt="" width="596" height="293" /></a></p>
<p>In generale è buona norma specificare un certificato sviluppatore per la configurazione <em>debug</em> e un certificato distribuzione per la configurazione <em>release</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/08/12/xcode-error-starting-executable-error-launching-remote-program-failed-to-get-the-task-for-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MapKit, zoom sulla posizione dell&#8217;utente (user location) con MKMapView</title>
		<link>http://www.massimooliviero.net/2011/07/29/mapkit-zoom-sulla-posizione-dellutente-user-location-con-mkmapview/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapkit-zoom-sulla-posizione-dellutente-user-location-con-mkmapview</link>
		<comments>http://www.massimooliviero.net/2011/07/29/mapkit-zoom-sulla-posizione-dellutente-user-location-con-mkmapview/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 19:56:24 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[iOS tips&tricks]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[IPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[MapKit]]></category>
		<category><![CDATA[MKMapView]]></category>
		<category><![CDATA[UserLocation]]></category>
		<category><![CDATA[Zoom]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=858</guid>
		<description><![CDATA[Piccolo tips della settimana: zoomare la mappa sulla posizione dell&#8217;utente. Esigenza molto comune ma non così semplice da realizzare come sembra. Infatti anche se è possibile sfruttare la proprietà userLocation della classe MKMapView questa potrebbe non essere valorizzata in fase di load della view. Questo è naturale in quanto per ottenere la posizione dell&#8217;utente ci possono volere [...]]]></description>
			<content:encoded><![CDATA[<p>Piccolo tips della settimana: <em>zoomare</em> la mappa sulla posizione dell&#8217;utente. Esigenza molto comune ma non così semplice da realizzare come sembra. Infatti anche se è possibile sfruttare la proprietà <strong><em>userLocation</em></strong> della classe <strong><em>MKMapView</em></strong> questa potrebbe non essere valorizzata in fase di <em><strong>load</strong></em> della view. Questo è naturale in quanto per ottenere la posizione dell&#8217;utente ci possono volere alcuni secondi in base alla disponibiltà del sistema <strong><em>GPS</em></strong>. Come fare allora ad effettuare uno zoom quando la posizione dell&#8217;utente è disponibile? In questo modo:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad
<span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// imposto il controller come delegate della mappa</span>
    self.mapView.delegate <span style="color: #002200;">=</span> self;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// chiedo alla mappa di visualizzare la posizione del device</span>
    <span style="color: #11740a; font-style: italic;">// questa operazione potrebbe durare qualche secondo</span>
    self.mapView.showUserLocation <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// questo metodo è invocato ogni volta che una (o più)</span>
<span style="color: #11740a; font-style: italic;">// annotation view è aggiunta alla mappa, compresa</span>
<span style="color: #11740a; font-style: italic;">// l'annotazione che rappresenta la posizione del device</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>mapView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MKMapView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>mv didAddAnnotationViews<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>views
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span>MKAnnotationView <span style="color: #002200;">*</span>annotationView <span style="color: #a61390;">in</span> views<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>annotationView.annotation <span style="color: #002200;">==</span> self.mapView.userLocation<span style="color: #002200;">&#41;</span>
        <span style="color: #002200;">&#123;</span>
            MKCoordinateRegion region;
            MKCoordinateSpan span;
&nbsp;
            span.latitudeDelta <span style="color: #002200;">=</span> <span style="color: #2400d9;">0.15</span>;
            span.longitudeDelta <span style="color: #002200;">=</span> <span style="color: #2400d9;">0.15</span>;
&nbsp;
            region.span <span style="color: #002200;">=</span> span;
            region.center <span style="color: #002200;">=</span> self.mapView.userLocation.location.coordinate;
&nbsp;
            <span style="color: #002200;">&#91;</span>self.mapView setRegion<span style="color: #002200;">:</span>region animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
            <span style="color: #002200;">&#91;</span>self.mapView regionThatFits<span style="color: #002200;">:</span>region<span style="color: #002200;">&#93;</span>;
        <span style="color: #002200;">&#125;</span>
    <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>In pratica sfruttando il metodo <strong><em><a href="http://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html#//apple_ref/occ/intfm/MKMapViewDelegate/mapView:didAddAnnotationViews:">didAddAnnotationViews</a></em></strong> è possibile intercettare quando la posizione dell&#8217;utente è visualizzata sulla mappa ed effettuare uno zoom solo quando è necessario. Il tutto senza l&#8217;uso del <strong><em>CLLocationManager</em></strong>, il che ci risparmia un pò di codice che, a mio avviso, risulterebbe ridondante.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/07/29/mapkit-zoom-sulla-posizione-dellutente-user-location-con-mkmapview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone come forzare l&#8217;interface orientation (landscape o portrait)</title>
		<link>http://www.massimooliviero.net/2011/07/28/iphone-come-forzare-linterface-orientation-landscape-o-portrait/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iphone-come-forzare-linterface-orientation-landscape-o-portrait</link>
		<comments>http://www.massimooliviero.net/2011/07/28/iphone-come-forzare-linterface-orientation-landscape-o-portrait/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 16:11:25 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Landscape]]></category>
		<category><![CDATA[Orientation]]></category>
		<category><![CDATA[Portrait]]></category>
		<category><![CDATA[UIDevice]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=853</guid>
		<description><![CDATA[In certe occasioni è indispensabile forzare l&#8217;interface orientation di una view. Pensiamo ad una applicazione che voglia visualizzare un contenuto e che questo contenuto sia fruibile solo in landscape. Normalmente l&#8217;utente parte da una posizione portrait (verticale) del device. Si vuole che all&#8217;entrata di una certa view l&#8217;orientation si sposti in landscape in modo automatico [...]]]></description>
			<content:encoded><![CDATA[<p>In certe occasioni è indispensabile forzare l&#8217;<em><strong>interface orientation</strong></em> di una <em><strong>view</strong></em>. Pensiamo ad una applicazione che voglia visualizzare un contenuto e che questo contenuto sia fruibile solo in <em><strong>landscape</strong></em>. Normalmente l&#8217;utente parte da una posizione <em><strong>portrait</strong></em> (verticale) del device. Si vuole che all&#8217;entrata di una certa view l&#8217;orientation si sposti in <em>landscape</em> in modo automatico anche se il <em>device</em> è ancora in posizione verticale. Bene non esiste una metodo ufficiale per questa attività. Esistono però due soluzioni alternative valide, ognuna con i suoi pro e i suoi contro e sono:</p>
<ol>
<li>Utilizzare una proprietà non documentata della classe <em><strong>UIDevice</strong></em></li>
<li>Gestire manualmente la rotazione di tutti gli elementi grafici</li>
</ol>
<div>Il primo approccio è molto semplice e consiste in una semplice riga di codice:</div>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIDevice currentDevice<span style="color: #002200;">&#93;</span> setOrientation<span style="color: #002200;">:</span>UIInterfaceOrientationLandscapeRight<span style="color: #002200;">&#93;</span>;</pre></div></div>

<div>Pur essendo una soluzione molto semplice e compatta presenta una serie di rischi:</div>
<div>
<ol>
<li>Genera un warning  in compilazione in quanto non è una funzione esposta dall&#8217;SDK</li>
<li>Non è garantito che funzioni con le versioni future dell&#8217;SDK proprio perché non è ufficialmente supportata</li>
</ol>
<div>Il secondo approccio prevede la gestione manuale della rotazione di tutti gli elementi, in questo modo:</div>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewWillAppear<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>animated
<span style="color: #002200;">&#123;</span>
    UIScreen <span style="color: #002200;">*</span>screen <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIScreen mainScreen<span style="color: #002200;">&#93;</span>;
    CGFloat screenWidth <span style="color: #002200;">=</span> screen.bounds.size.width;
    CGFloat screenHeight <span style="color: #002200;">=</span> screen.bounds.size.height;
&nbsp;
    UIAccelerationValue x <span style="color: #002200;">=</span> self.navigationController.navigationBar.frame.origin.x;
    UIAccelerationValue y <span style="color: #002200;">=</span> self.navigationController.navigationBar.frame.origin.y;
&nbsp;
    <span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;orientation&quot;</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>0.5f<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>UIView setAnimationCurve<span style="color: #002200;">:</span>UIViewAnimationCurveEaseInOut<span style="color: #002200;">&#93;</span>;
&nbsp;
    self.navigationController.view.transform <span style="color: #002200;">=</span> CGAffineTransformIdentity;
    self.navigationController.view.transform <span style="color: #002200;">=</span> CGAffineTransformMakeRotation<span style="color: #002200;">&#40;</span>M_PI_2<span style="color: #002200;">&#41;</span>;
    self.navigationController.view.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>0.0f, 0.0f, 320.0f, 480.0f<span style="color: #002200;">&#41;</span>;
    self.navigationController.view.center <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>screenWidth<span style="color: #002200;">/</span><span style="color: #2400d9;">2.0</span>, screenHeight<span style="color: #002200;">/</span><span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>;
    self.navigationController.navigationBar.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>x, y, <span style="color: #2400d9;">480</span>, <span style="color: #2400d9;">32</span><span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> setStatusBarOrientation<span style="color: #002200;">:</span>UIInterfaceOrientationLandscapeRight animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewWillDisappear<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>animated
<span style="color: #002200;">&#123;</span>
    UIScreen <span style="color: #002200;">*</span>screen <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIScreen mainScreen<span style="color: #002200;">&#93;</span>;
    CGFloat screenWidth <span style="color: #002200;">=</span> screen.bounds.size.width;
    CGFloat screenHeight <span style="color: #002200;">=</span> screen.bounds.size.height;
&nbsp;
    UIAccelerationValue x <span style="color: #002200;">=</span> self.navigationController.navigationBar.frame.origin.x;
    UIAccelerationValue y <span style="color: #002200;">=</span> self.navigationController.navigationBar.frame.origin.y;
&nbsp;
    <span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;orientation&quot;</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>0.5f<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>UIView setAnimationCurve<span style="color: #002200;">:</span>UIViewAnimationCurveEaseInOut<span style="color: #002200;">&#93;</span>;
    self.navigationController.view.transform <span style="color: #002200;">=</span> CGAffineTransformIdentity;
    self.navigationController.view.transform <span style="color: #002200;">=</span> CGAffineTransformMakeRotation<span style="color: #002200;">&#40;</span>M_PI <span style="color: #002200;">*</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
    self.navigationController.view.bounds <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>0.0f, 0.0f, 320.0f, 480.0f<span style="color: #002200;">&#41;</span>;
    self.navigationController.view.center <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>screenWidth<span style="color: #002200;">/</span><span style="color: #2400d9;">2.0</span>, screenHeight<span style="color: #002200;">/</span><span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>;
    <span style="color: #002200;">&#91;</span>self.navigationController.navigationBar setFrame<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span>x, y, <span style="color: #2400d9;">320</span>, <span style="color: #2400d9;">44</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> setStatusBarOrientation<span style="color: #002200;">:</span>UIInterfaceOrientationPortrait animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<div>In pratica viene applicata una rotazione di 90° sul <em><strong>NavigationController</strong></em> (che contiene tutti gli elementi) in entrata e una trasformazione inversa in uscita. Da notare che la <em><strong>NavigationBar</strong></em> presenta due dimensioni diverse se è in landscape (32 px) o in portrait (44 px). Questa soluzione risulta compatibile anche con le versioni future dell&#8217;SDK però presenta i seguenti problemi:</div>
<div>
<ol>
<li>C&#8217;è un leggero difetto grafico in fase di rotazione se la <em>NavigationBar</em> contiene elementi al suo interno come button o immagini. In pratica c&#8217;è un leggero sfarfallio degli elementi che si adattano alla nuova dimensione della <em>NavigationBar</em>. Non mi è ancora chiaro questo problema.</li>
<li>E&#8217; sicuramente più lento di una soluzione nativa</li>
</ol>
<div>A voi la scelta.</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/07/28/iphone-come-forzare-linterface-orientation-landscape-o-portrait/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS colorare la NavigationBar More e il Configure di un UITabBarController (color)</title>
		<link>http://www.massimooliviero.net/2011/07/25/ios-colorare-la-navigationbar-more-e-il-configure-di-un-uitabbarcontroller/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ios-colorare-la-navigationbar-more-e-il-configure-di-un-uitabbarcontroller</link>
		<comments>http://www.massimooliviero.net/2011/07/25/ios-colorare-la-navigationbar-more-e-il-configure-di-un-uitabbarcontroller/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 20:19:19 +0000</pubDate>
		<dc:creator>Massimo</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[IPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[NavigationBar]]></category>
		<category><![CDATA[UINavigationController]]></category>
		<category><![CDATA[UITabBarController]]></category>
		<category><![CDATA[UITabBarItem]]></category>

		<guid isPermaLink="false">http://www.massimooliviero.net/?p=830</guid>
		<description><![CDATA[Il comportamento di default della classe UITabBarController è quello di aggiungere un TabBarItem More quando ci sono più di 5 item . Il more è uno speciale NavigationBarController  con all&#8217;interno una UITableView e l&#8217;elenco degli item non visibili nella schermata principale (Fig. 1). E&#8217; possibile colorare la NavigationBar agendo direttamente su una proprietà specifica della [...]]]></description>
			<content:encoded><![CDATA[<p>Il comportamento di default della classe <strong><em>UITabBarController</em></strong> è quello di aggiungere un <em>TabBarItem</em> <strong>More</strong> quando ci sono più di 5 item . Il <em><strong>more</strong></em> è uno speciale <em>NavigationBarController</em>  con all&#8217;interno una UITableView e l&#8217;elenco degli item non visibili nella schermata principale (Fig. 1).</p>
<div id="attachment_831" class="wp-caption aligncenter" style="width: 219px"><a href="http://www.massimooliviero.net/wp-content/uploads/2011/07/more.png"><img class="size-full wp-image-831 " title="more" src="http://www.massimooliviero.net/wp-content/uploads/2011/07/more.png" alt="" width="209" height="311" /></a><p class="wp-caption-text">Figura 1 - un UITabBarController con il tasto More.</p></div>
<p>E&#8217; possibile colorare la <em>NavigationBar</em> agendo direttamente su una proprietà specifica della classe <em>UITabBarController</em> all&#8217;interno del nostro<strong><em> AppDelegate.m </em></strong>in questo modo:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>application<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIApplication <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>application didFinishLaunchingWithOptions<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>launchOptions
<span style="color: #002200;">&#123;</span>
   UIColor <span style="color: #002200;">*</span>c <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor colorWithRed<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">102.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> green<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">153.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> blue<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">51.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> alpha<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
   UINavigationController <span style="color: #002200;">*</span>nav <span style="color: #002200;">=</span> self.tabBarController.moreNavigationController;
   UINavigationBar <span style="color: #002200;">*</span>bar <span style="color: #002200;">=</span> nav.navigationBar;
   bar.tintColor <span style="color: #002200;">=</span> c;
&nbsp;
   self.window.rootViewController <span style="color: #002200;">=</span> self.tabBarController;
   <span style="color: #002200;">&#91;</span>self.window makeKeyAndVisible<span style="color: #002200;">&#93;</span>;
   <span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p style="text-align: left;">A questo punto la <em>NavigationBar</em> risulta correttamente colorata (Fig. 2).</p>
<div id="attachment_836" class="wp-caption aligncenter" style="width: 237px"><a href="http://www.massimooliviero.net/wp-content/uploads/2011/07/more_colorato.png"><img class="size-full wp-image-836" title="more_colorato" src="http://www.massimooliviero.net/wp-content/uploads/2011/07/more_colorato.png" alt="" width="227" height="146" /></a><p class="wp-caption-text">Figura 2 - Il more colorato</p></div>
<p style="text-align: left;">E se premiamo il tasto Edit? Beh il risultato la figura 3 non lascia scampo, un&#8217;altra NavigationBar con il colore standard!</p>
<div id="attachment_840" class="wp-caption aligncenter" style="width: 209px"><a href="http://www.massimooliviero.net/wp-content/uploads/2011/07/configure1.png"><img class="size-medium wp-image-840" title="configure" src="http://www.massimooliviero.net/wp-content/uploads/2011/07/configure1-199x300.png" alt="" width="199" height="300" /></a><p class="wp-caption-text">Figura 3 - Il Configure</p></div>
<p>Come fare? Con un trucchetto, prima bisogna impostare come <strong><em>UITabBarController delegate</em></strong> la classe <em>AppDelegate</em> in questo modo:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>application<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIApplication <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>application didFinishLaunchingWithOptions<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>launchOptions
<span style="color: #002200;">&#123;</span>
   UIColor <span style="color: #002200;">*</span>c <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor colorWithRed<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">102.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> green<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">153.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> blue<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">51.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> alpha<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
   UINavigationController <span style="color: #002200;">*</span>nav <span style="color: #002200;">=</span> self.tabBarController.moreNavigationController;
   UINavigationBar <span style="color: #002200;">*</span>bar <span style="color: #002200;">=</span> nav.navigationBar;
   bar.tintColor <span style="color: #002200;">=</span> c;
&nbsp;
   <span style="color: #11740a; font-style: italic;">// impostare il delegate sul tabbarcontroller</span>
   self.tabBarController.delegate <span style="color: #002200;">=</span> self;
&nbsp;
   self.window.rootViewController <span style="color: #002200;">=</span> self.tabBarController;
   <span style="color: #002200;">&#91;</span>self.window makeKeyAndVisible<span style="color: #002200;">&#93;</span>;
   <span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>e poi creare il metodo <strong><em>willBeginCustomizingViewControllers</em></strong> che verrà richiamato al momento opportuno:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>tabBarController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITabBarController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>controller willBeginCustomizingViewControllers<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>viewControllers
<span style="color: #002200;">&#123;</span>
    UIView <span style="color: #002200;">*</span>editView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>controller.view.subviews objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
    UINavigationBar <span style="color: #002200;">*</span>modalNavBar <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>editView.subviews objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
    modalNavBar.tintColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor colorWithRed<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">102.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> green<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">153.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> blue<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">51.0</span><span style="color: #002200;">/</span><span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span> alpha<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
&nbsp;
    editView.backgroundColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor whiteColor<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Ed ecco alla fine il risultato voluto da ogni punto di vista.</p>
<div id="attachment_844" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.massimooliviero.net/wp-content/uploads/2011/07/Screen-Shot-2011-07-25-at-10.16.10-PM.png"><img class="size-medium wp-image-844" title="config_colorato" src="http://www.massimooliviero.net/wp-content/uploads/2011/07/Screen-Shot-2011-07-25-at-10.16.10-PM-300x217.png" alt="" width="300" height="217" /></a><p class="wp-caption-text">Figura 4 - Il configure colorato</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.massimooliviero.net/2011/07/25/ios-colorare-la-navigationbar-more-e-il-configure-di-un-uitabbarcontroller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

