<?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/"
	
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Get Set Games &#187; UIApplication</title>
	<atom:link href="http://getsetgames.com/tag/uiapplication/feed/" rel="self" type="application/rss+xml" />
	<link>http://getsetgames.com</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 19:21:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/><cloud domain='getsetgames.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<link rel="http://api.friendfeed.com/2008/03#sup" xmlns="http://www.w3.org/2005/Atom" type="application/json" href="http://friendfeed.com/api/public-sup.json#5c973c50be"/>		<item>
		<title>How to Open the SMS App With a Phone Number</title>
		<link>http://getsetgames.com/2009/12/24/iphonedev-advent-tip-24-how-to-open-the-sms-app-with-a-phone-number/</link>
		<comments>http://getsetgames.com/2009/12/24/iphonedev-advent-tip-24-how-to-open-the-sms-app-with-a-phone-number/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 19:49:49 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=1073</guid>
		<description><![CDATA[It&#8217;s the day before Christmas, so this is the last post in our advent tip series. We&#8217;ve really enjoyed writing about so many little things that are so easily accomplished with the iPhone SDK and we hope that they&#8217;ve helped you in developing your iPhone apps. This may be the last blog post in this [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s the day before Christmas, so this is the last post in our <a href="http://getsetgames.com/tag/advent/">advent tip series</a>. We&#8217;ve really enjoyed writing about so many little things that are so easily accomplished with the iPhone SDK and we hope that they&#8217;ve helped you in developing your iPhone apps. This may be the last blog post in this series, but you can be sure we&#8217;ll still be writing about our adventures with iPhone, cocos2d and OpenFeint development.</p>
<h2>Less Yap, More Tip</h2>
<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/messages.png" alt="" title="messages" width="69" height="85" class="alignright size-full wp-image-1074" />Today&#8217;s advent tip is how to open the Messages app (aka the SMS app) with a specific phone number populated in the <strong>To:</strong> field. This is accomplished with great ease because the iPhone has implemented the <strong>sms:</strong> URI scheme. Therefore, we can use the UIApplication class&#8217; openURL method, which we have seen before when we discussed how to <a href="http://getsetgames.com/2009/12/12/iphonedev-advent-tip-12-how-to-dial-a-phone-number/">dial a phone number</a>, <a href="http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/">pre-compose an email</a>, and yes, even <a href="http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/">open a URL</a>.</p>
<p>So here it is: the one line of code you need to pop open the SMS app with a phone number:</p>

<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>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> openURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;sms:5555555555&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/24/iphonedev-advent-tip-24-how-to-open-the-sms-app-with-a-phone-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/messages.png" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/messages.png" medium="image">
			<media:title type="html">messages</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Suspend Touch Input</title>
		<link>http://getsetgames.com/2009/12/23/iphonedev-advent-tip-23-how-to-suspend-touch-input/</link>
		<comments>http://getsetgames.com/2009/12/23/iphonedev-advent-tip-23-how-to-suspend-touch-input/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 00:06:43 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=1069</guid>
		<description><![CDATA[Have you ever encountered a situation where you wish you could just pause and resume touch input while developing an iPhone app? Sure, you could always increase the complexity of your input handling by considering the state of any number of variables, but there are some times when just switching input off and on would [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever encountered a situation where you wish you could just pause and resume touch input while developing an iPhone app? Sure, you could always increase the complexity of your input handling by considering the state of any number of variables, but there are some times when just switching input off and on would be easiest.</p>
<p>We had a number of cases like this when developing <a href="http://getsetgames.com/games/addicus/">Addicus</a>. In particular, because we have both the game and game over screens operating in a single cocos2d scene, we were noticing some bugs that occurred because of the way we handled input. This was solved by suspending input for brief periods of time.</p>
<h2>Input Goes Off</h2>
<p>Here&#8217;s how to tell your iPhone app to stop responding to touch events in just one line of code:</p>

<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>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> beginIgnoringInteractionEvents<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h2>Input Goes On</h2>
<p>And as you might expect, resuming responding to touch input events is similarly easy:</p>

<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>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> endIgnoringInteractionEvents<span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/23/iphonedev-advent-tip-23-how-to-suspend-touch-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>How to Prevent the iPhone from Sleeping</title>
		<link>http://getsetgames.com/2009/12/17/iphonedev-advent-tip-17-how-to-prevent-the-iphone-from-sleeping/</link>
		<comments>http://getsetgames.com/2009/12/17/iphonedev-advent-tip-17-how-to-prevent-the-iphone-from-sleeping/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 23:10:53 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=994</guid>
		<description><![CDATA[Left idle, the iPhone goes into sleep mode after about a minute. This narcoleptic behaviour saves on battery life, but there are situations where you would not want the device to go to sleep. For instance, in the middle of a multiplayer game that is turn-based, such as chess. You could wait for longer than [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep.jpeg" alt="put-the-iphone-to-sleep" title="put-the-iphone-to-sleep" width="200" class="alignright size-full wp-image-995" /></p>
<p>Left idle, the iPhone goes into sleep mode after about a minute. This narcoleptic behaviour saves on battery life, but there are situations where you would not want the device to go to sleep. For instance, in the middle of a multiplayer game that is turn-based, such as chess. You could wait for longer than a minute for your opponent to make make their move and you wouldn&#8217;t want to miss it when they did.</p>
<p>To keep the iPhone awake and alert, simply run the following line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><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>;</pre></div></div>

<p>Do use this tip sparingly though. The iPhone&#8217;s power is unmatched, to be sure, but unfortunately it is not unlimited. </p>
]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/17/iphonedev-advent-tip-17-how-to-prevent-the-iphone-from-sleeping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep-150x150.jpg" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep.jpeg" medium="image">
			<media:title type="html">put-the-iphone-to-sleep</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep-150x150.jpg" />
		</media:content>
	</item>
		<item>
		<title>How to Show the Network Activity Indicator</title>
		<link>http://getsetgames.com/2009/12/16/iphonedev-advent-tip-16-how-to-show-the-network-activity-indicator/</link>
		<comments>http://getsetgames.com/2009/12/16/iphonedev-advent-tip-16-how-to-show-the-network-activity-indicator/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 03:17:32 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=987</guid>
		<description><![CDATA[The network activity indicator is like the UIActivityIndicatorView we previously discussed, only it sits on the status bar, it is smaller, and believe it or not, it is even easier to manipulate. It&#8217;s the little rotating wheel of bars (pictured right) that shows up on the status bar whenever your iPhone is accessing the network. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM.png" alt="Screen shot 2009-12-16 at 10.14.26 PM" title="Screen shot 2009-12-16 at 10.14.26 PM" width="172" height="143" class="alignright size-full wp-image-990" />The network activity indicator is like the <a href="http://getsetgames.com/2009/12/03/iphonedev-advent-tip-3-how-to-display-an-activity-indicator-with-uiactivityindicatorview/">UIActivityIndicatorView</a> we previously discussed, only it sits on the status bar, it is smaller, and believe it or not, it is even easier to manipulate. It&#8217;s the little rotating wheel of bars (pictured right) that shows up on the status bar whenever your iPhone is accessing the network.</p>
<h2>Show It</h2>
<p>If you would like to let your users know that your iPhone app is currently swapping data with the network, you can do so with this simple line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><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>;</pre></div></div>

<h2>Hide It</h2>
<p>You guessed it: once you&#8217;re done showing it, to hide it again, just set the same UIApplication property to NO like so.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><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>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/16/iphonedev-advent-tip-16-how-to-show-the-network-activity-indicator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM-150x143.png" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM.png" medium="image">
			<media:title type="html">Screen shot 2009-12-16 at 10.14.26 PM</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM-150x143.png" />
		</media:content>
	</item>
		<item>
		<title>How to Retrieve Your App Delegate Singleton Instance</title>
		<link>http://getsetgames.com/2009/12/14/iphonedev-advent-tip-14-how-to-retrieve-your-app-delegate-singleton-instance/</link>
		<comments>http://getsetgames.com/2009/12/14/iphonedev-advent-tip-14-how-to-retrieve-your-app-delegate-singleton-instance/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 02:57:02 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[delegate]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=980</guid>
		<description><![CDATA[You should be familiar with the application delegate class if you have ever developed any kind of iPhone app. It is the class that contains your app&#8217;s applicationDidFinishLaunching which most if not all apps use as an entry point for execution. You might use it to keep track of application-level state variables or objects, for [...]]]></description>
			<content:encoded><![CDATA[<p>You should be familiar with the application delegate class if you have ever developed any kind of iPhone app. It is the class that contains your app&#8217;s applicationDidFinishLaunching which most if not all apps use as an entry point for execution. You might use it to keep track of application-level state variables or objects, for example. </p>
<p>As such, from time to time you will have a need to retrieve your app&#8217;s application delegate instance. You can retrieve it from anywhere within your app by running the following single line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">MyAppDelegateClass <span style="color: #002200;">*</span>app <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> delegate<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Just be sure to replace &#8220;MyAppDelegateClass&#8221; with your own iPhone app&#8217;s application delegate class name. </p>
]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/14/iphonedev-advent-tip-14-how-to-retrieve-your-app-delegate-singleton-instance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
	</item>
		<item>
		<title>How to Dial a Phone Number</title>
		<link>http://getsetgames.com/2009/12/12/iphonedev-advent-tip-12-how-to-dial-a-phone-number/</link>
		<comments>http://getsetgames.com/2009/12/12/iphonedev-advent-tip-12-how-to-dial-a-phone-number/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 01:05:32 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=956</guid>
		<description><![CDATA[With so many awesome games and apps on the iPhone, it is easy to forget that it can actually be used to make phone calls. No, really, it&#8217;s true! And as is the case with so many other pieces of functionality, this is easy to accomplish with the iPhone SDK. Like other phones, the iPhone [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/photo-4-200x300.jpg" alt="photo-4" title="photo-4" width="200" height="300" class="alignright size-medium wp-image-957" />With so many awesome games and apps on the iPhone, it is easy to forget that it can actually be used to make phone calls. No, really, it&#8217;s true! And as is the case with so many other pieces of functionality, this is easy to accomplish with the iPhone SDK.</p>
<p>Like other phones, the iPhone supports the <strong>tel</strong> application protocol in URLs. This means that all we need to use is the trusty openURL method of the UIApplication class. We have previously discussed this method when <a href="http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/">pre-composing emails</a> and, believe it or not, <a href="http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/">opening a URL</a>.</p>
<h2>The Code</h2>
<p>Here is how to dial a phone number from your iPhone app in one line of code:</p>

<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>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> openURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;tel:555-555-5555&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<h2>Dialing From a Web Page</h2>
<p>You can also put links in your web pages that dial a phone number on the iPhone by using the tel protocol like so:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a href=&quot;tel:555-555-5555&quot;&gt;Dial 555-555-5555&lt;/a&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/12/iphonedev-advent-tip-12-how-to-dial-a-phone-number/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/photo-4-150x150.jpg" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/photo-4.jpg" medium="image">
			<media:title type="html">photo-4</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/photo-4-150x150.jpg" />
		</media:content>
	</item>
		<item>
		<title>How to Hide (and Show) the Status Bar</title>
		<link>http://getsetgames.com/2009/12/11/iphonedev-advent-tip-11-how-to-hide-and-show-the-status-bar/</link>
		<comments>http://getsetgames.com/2009/12/11/iphonedev-advent-tip-11-how-to-hide-and-show-the-status-bar/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 00:59:35 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>
		<category><![CDATA[UIStatusBarHidden]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=943</guid>
		<description><![CDATA[On the iPhone&#8217;s 320&#215;480 screen, pixel real estate is at a premium, especially for games. Often, the status bar represents 20 pixels of height that you as a developer just can&#8217;t afford to give away. Fortunately there are 2 simple ways to remove the status bar. UIStatusBarHidden The first way is by adding a setting [...]]]></description>
			<content:encoded><![CDATA[<p>On the iPhone&#8217;s 320&#215;480 screen, pixel real estate is at a premium, especially for games. Often, the status bar represents 20 pixels of height that you as a developer just can&#8217;t afford to give away. Fortunately there are 2 simple ways to remove the status bar.</p>
<h2>UIStatusBarHidden</h2>
<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/uistatusbarhidden2.png" alt="uistatusbarhidden2" title="uistatusbarhidden2" width="315" height="62" class="alignright size-full wp-image-947" />The first way is by adding a setting to your app&#8217;s info.plist file called UIStatusBarHidden. This is ideal for apps that should never display the status bar. Just follow these steps to change the setting:</p>
<p>1. Open your iPhone app&#8217;s info.plist file.</p>
<p>2. Command-click and select Add Row.</p>
<p>3. Select &#8220;Status bar is initially hidden&#8221; from the drop down that appears.</p>
<p>4. Check the checkbox that appears next to the new row.</p>
<p>You could also add this setting to your app&#8217;s info.plist file by opening it in a text editor and adding the following 2 XML tags inside the &lt;dict&gt; tag:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>UIStatusBarHidden<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;true</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	...</pre></div></div>

<h2>How to Do it With Code</h2>
<p>If you need the status bar to appear and disappear at runtime, then you will need to use code to do so. You can hide the status bar with one line of code:</p>

<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>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> setStatusBarHidden<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span> animated<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>And to show it again, simply call the above line and pass &#8220;NO&#8221; into setStatusBarHidden instead of &#8220;YES&#8221;. You can also fade the status bar in and out by passing &#8220;YES&#8221; into the &#8220;animated&#8221; part of the message. </p>
]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/11/iphonedev-advent-tip-11-how-to-hide-and-show-the-status-bar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/uistatusbarhidden2-150x62.png" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/uistatusbarhidden2.png" medium="image">
			<media:title type="html">uistatusbarhidden2</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/uistatusbarhidden2-150x62.png" />
		</media:content>
	</item>
		<item>
		<title>How to Open the Mail App With a Pre-Composed HTML Email</title>
		<link>http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/</link>
		<comments>http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 19:55:15 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=832</guid>
		<description><![CDATA[Have you ever wanted to open the Mail app with a pre-composed email? Then today&#8217;s iPhone development advent tip is the one for you! This has many uses, but a common one is a tell-a-friend feature in apps. If you attach the code from this tip to a button, you can give your users a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://getsetgames.com/wp-content/uploads/2009/12/photo-2-1.jpg"><img src="http://getsetgames.com/wp-content/uploads/2009/12/photo-2-1-200x300.jpg" alt="photo 2-1" title="photo 2-1" width="200" height="300" class="alignright size-medium wp-image-856" /></a>Have you ever wanted to open the Mail app with a pre-composed email? Then today&#8217;s iPhone development advent tip is the one for you! This has many uses, but a common one is a tell-a-friend feature in apps. If you attach the code from this tip to a button, you can give your users a way to promote your app to their friends via the iPhone&#8217;s built in Mail app.</p>
<h2>A Handy Function</h2>
<p>The sendEmailTo function, seen below, can be included in any class in your app. This function gives you a simple interface to send emails. It allows you to define &#8220;to&#8221; addresses, &#8220;cc&#8221; addresses, &#8220;bcc&#8221; addresses, a subject and a body. The body supports HTML tags.</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>sendEmailTo<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>to withCC<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>cc withBCC<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>bcc withSubject<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>subject withBody<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>body <span style="color: #002200;">&#123;</span>
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> url <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;mailto:?to=%@&amp;cc=%@&amp;bcc=%@&amp;subject=%@&amp;body=%@&quot;</span>,
					  <span style="color: #002200;">&#91;</span>to stringByAddingPercentEscapesUsingEncoding<span style="color: #002200;">:</span>NSASCIIStringEncoding<span style="color: #002200;">&#93;</span>,
					  <span style="color: #002200;">&#91;</span>cc stringByAddingPercentEscapesUsingEncoding<span style="color: #002200;">:</span>NSASCIIStringEncoding<span style="color: #002200;">&#93;</span>,
					  <span style="color: #002200;">&#91;</span>bcc stringByAddingPercentEscapesUsingEncoding<span style="color: #002200;">:</span>NSASCIIStringEncoding<span style="color: #002200;">&#93;</span>,
					  <span style="color: #002200;">&#91;</span>subject stringByAddingPercentEscapesUsingEncoding<span style="color: #002200;">:</span>NSASCIIStringEncoding<span style="color: #002200;">&#93;</span>,
					  <span style="color: #002200;">&#91;</span>body stringByAddingPercentEscapesUsingEncoding<span style="color: #002200;">:</span>NSASCIIStringEncoding<span style="color: #002200;">&#93;</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> openURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span>url<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p><strong>NOTE:</strong> Running this function in the iPhone Simulator will have no effect because the simulator does not include the iPhone&#8217;s Mail app. To see the effects of this function, it must be run on a device.</p>
<h2>Example Usage</h2>
<p>Once you have that message defined in one of your classes, you can open the Mail app with a pre-composed email with just one message call. The following example opens an email and specifies a to, cc and bcc address. It populates the subject with &#8220;Addicus&#8221; and populates the body with a short message about Addicus that includes a link and an image (which is also a link). As you can see, this is done with good old HTML tags. This results in the email in the above screenshot.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>self sendEmailTo<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;mom@example.com&quot;</span>
           withCC<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dad@example.com&quot;</span>
          withBCC<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;asecretfriend@example.com&quot;</span>
      withSubject<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Addicus&quot;</span>
         withBody<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&lt;p&gt;Check out this game, &lt;a href='http://addicusgame.com'&gt;Addicus&lt;/a&gt;, for the iPhone and iPod Touch. It's super-addictive!&lt;/p&gt;&lt;p&gt;&lt;a href='http://addicusgame.com'&gt;&lt;img src='http://getsetgames.com/wp-content/uploads/2009/11/icon_addicus.png'/&gt;&lt;/a&gt;&lt;/p&gt;&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>If you would like to have the user specify the to, cc and bcc addresses themselves, as you would in the case of a tell-a-friend button, then you would call the following message:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>self sendEmailTo<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span>
           withCC<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span>
          withBCC<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span>
      withSubject<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Addicus&quot;</span>
         withBody<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&lt;p&gt;Check out this game, &lt;a href='http://addicusgame.com'&gt;Addicus&lt;/a&gt;, for the iPhone and iPod Touch. It's super-addictive!&lt;/p&gt;&lt;p&gt;&lt;a href='http://addicusgame.com'&gt;&lt;img src='http://getsetgames.com/wp-content/uploads/2009/11/icon_addicus.png'/&gt;&lt;/a&gt;&lt;/p&gt;&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/photo-2-1-150x150.jpg" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/photo-2-1.jpg" medium="image">
			<media:title type="html">photo 2-1</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/photo-2-1-150x150.jpg" />
		</media:content>
	</item>
		<item>
		<title>Eliminating class dependencies on your application delegate</title>
		<link>http://getsetgames.com/2009/12/04/iphonedev-advent-tip-4-eliminating-class-dependencies-on-your-application-delegate/</link>
		<comments>http://getsetgames.com/2009/12/04/iphonedev-advent-tip-4-eliminating-class-dependencies-on-your-application-delegate/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 14:00:53 +0000</pubDate>
		<dc:creator>Rob Segal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=739</guid>
		<description><![CDATA[Ever have the need to call a method inside your app delegate from an arbitrary place in your code?  We&#8217;ve had to deal with this issue in a few cases working on our new project.  We&#8217;re making use of a UIScrollView instance to give us that popular flick scroll movement that is so popular on [...]]]></description>
			<content:encoded><![CDATA[<p>Ever have the need to call a method inside your app delegate from an arbitrary place in your code?  We&#8217;ve had to deal with this issue in a few cases working on our <a href="http://getsetgames.com/2009/11/27/next-game-from-get-se/">new project</a>.  We&#8217;re making use of a <em>UIScrollView</em> instance to give us that popular flick scroll movement that is so popular on the iPhone.  We&#8217;ve found that alot of people have been interested in doing the same thing and you can read our blog on <a href="http://getsetgames.com/2009/08/21/cocos2d-and-uiscrollview/">that particular challenge here</a>.  We have a <em>UIScrollView</em> instance sitting inside our app delegate and there are certain parts of our code where we need to move that <em>UIScrollView</em> among different layers in Cocos 2D.  To do that we need access to the scroll view instance itself.  That results in code like the following&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">myAppDelegate <span style="color: #002200;">*</span>app <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> delegate<span style="color: #002200;">&#93;</span>;
UIScrollView <span style="color: #002200;">*</span>appOverlayScrollView  <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>UIScrollView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>app.view;
<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>app window<span style="color: #002200;">&#93;</span> sendSubviewToBack<span style="color: #002200;">:</span>appOverlayScrollView<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>This creates a messy dependency between an arbitrary class and the app delegate class.  Wouldn&#8217;t it be great if we could send a message to the app delegate and tell it to move the scroll view to the front or back maintaining encapsulation?  Turns out you can indeed do this.  The <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html"><em>UIApplication</em></a> class contains a method called <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/sendAction:to:from:forEvent:"><em>sendAction</em></a> which is normally used to send an action message identified by a selector to a specified target.  This method can easily be used to call selectors in any object so the above code can be converted to&#8230;</p>

<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>UIApplication sharedApplication<span style="color: #002200;">&#93;</span>
sendAction<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>bringScrollViewToFront<span style="color: #002200;">&#41;</span>
to<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> delegate<span style="color: #002200;">&#93;</span>
from<span style="color: #002200;">:</span>self
forEvent<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>The only downside to this approach is that I haven&#8217;t found a way to supply arguments along with the selector so you need to be calling a method with no arguments.  If you know of a way around this issue please do let me know. </p>
]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/04/iphonedev-advent-tip-4-eliminating-class-dependencies-on-your-application-delegate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>How to Open a URL in Safari</title>
		<link>http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/</link>
		<comments>http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 01:40:44 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=650</guid>
		<description><![CDATA[Tis the season to broaden your iPhone dev chops! We have been developing on the iPhone platform for about 6 months now and it turns out that in that time, you tend to learn lots of little tips and tricks. Since we&#8217;re overcome by the spirit of giving around this time of year, we are [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://getsetgames.com/wp-content/uploads/2009/12/1.png"><img src="http://getsetgames.com/wp-content/uploads/2009/12/1-156x300.png" alt="1" title="1" width="156" height="300" class="alignright size-medium wp-image-656" /></a>Tis the season to broaden your iPhone dev chops! We have been developing on the iPhone platform for about 6 months now and it turns out that in that time, you tend to learn lots of little tips and tricks. Since we&#8217;re overcome by the spirit of giving around this time of year, we are going to be posting 24 of these bite-sized iPhone development tips, 1 every day between now and Christmas day. Consider it an advent calendar of iPhone dev tip goodies.</p>
<h2>On With The First Tip!</h2>
<p>Say you would like to open a URL in Safari. We used this on the &#8220;Get Set&#8221; button on the main menu of <a href="http://getsetgames.com/games/addicus/">Addicus</a>. Here is how to do it with just one line of code using the UIApplication class:<br />
<br/></p>

<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>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> openURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://getsetgames.com/&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/1-150x150.png" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/1.png" medium="image">
			<media:title type="html">1</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/1-150x150.png" />
		</media:content>
	</item>
	</channel>
</rss>
