<?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>Cone Code Development</title>
	<atom:link href="http://conecode.com/news/feed/" rel="self" type="application/rss+xml" />
	<link>http://conecode.com/news</link>
	<description>Design and Development News</description>
	<lastBuildDate>Fri, 29 Mar 2013 19:09:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>iOS How To – Adding a Loading Label to a (UIWebView)</title>
		<link>http://conecode.com/news/2013/03/ios-how-to-adding-a-loading-label-to-a-uiwebview/</link>
		<comments>http://conecode.com/news/2013/03/ios-how-to-adding-a-loading-label-to-a-uiwebview/#comments</comments>
		<pubDate>Thu, 21 Mar 2013 19:03:53 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iOS App Development for Beginners]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web App]]></category>
		<category><![CDATA[Xcode 4]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=662</guid>
		<description><![CDATA[If you already have an app with a Web View, you may want to add some kind of notification to the user that a website is being loaded, otherwise Apple will probably reject it. If you don&#8217;t have an app &#8230; <div class="readmore"><a href="http://conecode.com/news/2013/03/ios-how-to-adding-a-loading-label-to-a-uiwebview/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Finished-ScreenShot1-e1363893010156.png"><img class=" wp-image-687 alignleft" alt="Finished ScreenShot 2" src="http://conecode.com/news/wp-content/uploads/2013/03/Finished-ScreenShot1-201x300.png" width="101" height="150" /></a>If you already have an app with a <a title="iOS Tutorial – Creating a Web View (UIWebView)" href="http://conecode.com/news/2011/05/ios-tutorial-creating-a-web-view-uiwebview/" target="_blank">Web View</a>, you may want to add some kind of notification to the user that a website is being loaded, otherwise Apple will probably reject it. If you don&#8217;t have an app with a web view, I suggest you complete <a title="iOS Tutorial – Creating a Web View (UIWebView)" href="http://conecode.com/news/2011/05/ios-tutorial-creating-a-web-view-uiwebview/" target="_blank">THIS</a> tutorial before continuing.<span id="more-662"></span></p>
<p><span style="color: #ff0000;">1.</span> Open your existing Web View app.</p>
<p><span style="color: #ff0000;">2.</span> In the file view on the left, click on the <strong>MainStoryboard_iPhone.storyboard</strong> file:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Click-iPhone-storyboard.png"><img class="aligncenter size-full wp-image-679" alt="Click iPhone storyboard" src="http://conecode.com/news/wp-content/uploads/2013/03/Click-iPhone-storyboard.png" width="299" height="266" /></a></p>
<p><span style="color: #ff0000;">3.</span> Make sure at the top left of the screen your <strong>Editor</strong> and <strong>View</strong> buttons look like this:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Editor-View-1.png"><img class="aligncenter size-full wp-image-673" alt="Editor View 1" src="http://conecode.com/news/wp-content/uploads/2013/03/Editor-View-1.png" width="226" height="56" /></a></p>
<p><span style="color: #ff0000;">4.</span> At the top of the right properties sidebar, make sure the <strong>little shield</strong> is selected:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Little-Shield.png"><img class="aligncenter size-full wp-image-677" alt="Little Shield" src="http://conecode.com/news/wp-content/uploads/2013/03/Little-Shield.png" width="278" height="64" /></a></p>
<p><span style="color: #ff0000;">5.</span> At the bottom of the right properties bar, scroll up or down until you see the <strong>Label</strong> object:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Find-Label.png"><img class="aligncenter size-full wp-image-678" alt="Find Label" src="http://conecode.com/news/wp-content/uploads/2013/03/Find-Label.png" width="275" height="247" /></a></p>
<p><span style="color: #ff0000;">6.</span> <strong>Drag the Label</strong> object onto the the Web View in the Editor screen:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Drag-in-Label.png"><img class="aligncenter size-medium wp-image-664" alt="Drag in Label" src="http://conecode.com/news/wp-content/uploads/2013/03/Drag-in-Label-300x249.png" width="300" height="249" /></a></p>
<p><span style="color: #ff0000;">7.</span> <strong>Resize the Label</strong> you just dragged in to the desired size. You&#8217;ll notice I filled the whole screen:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Resize-Label.png"><img class="aligncenter size-medium wp-image-665" alt="Resize Label" src="http://conecode.com/news/wp-content/uploads/2013/03/Resize-Label-217x300.png" width="217" height="300" /></a></p>
<p><span style="color: #ff0000;">8.</span> In the properties sidebar, change the <strong>Color</strong>, <strong>Font</strong>, and <strong>Alignment</strong> to the following:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Color-Font-Alignment.png"><img class="aligncenter size-full wp-image-676" alt="Color Font Alignment" src="http://conecode.com/news/wp-content/uploads/2013/03/Color-Font-Alignment.png" width="249" height="71" /></a></p>
<p><span style="color: #ff0000;">9.</span> Near the bottom of the properties sidebar, change the <strong>Alpha</strong>, <strong>Background</strong> and <strong>Hidden</strong> to the following:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Alpha-Background-Hidden.png"><img class="aligncenter size-full wp-image-675" alt="Alpha Background Hidden" src="http://conecode.com/news/wp-content/uploads/2013/03/Alpha-Background-Hidden.png" width="246" height="74" /></a></p>
<p><span style="color: #ff0000;">10.</span> Double click the Label in the Editor window and change the text to <strong>&#8220;Loading&#8230;&#8221;</strong>:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Change-Text.png"><img class="aligncenter size-medium wp-image-674" alt="Change Text" src="http://conecode.com/news/wp-content/uploads/2013/03/Change-Text-300x116.png" width="300" height="116" /></a></p>
<p><span style="color: #ff0000;">11.</span> On the top right of the screen, set your <strong>Editor</strong> and <strong>View</strong> buttons to look like this:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Editor-View-2.png"><img class="aligncenter size-full wp-image-672" alt="Editor View 2" src="http://conecode.com/news/wp-content/uploads/2013/03/Editor-View-2.png" width="224" height="53" /></a></p>
<p>You should now see both your <strong>MainStoryboard_iPhone.storyboard</strong> editor and your ViewController.h editor:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Show-Editor-and-H.png"><img class="aligncenter size-medium wp-image-670" alt="Show Editor and H" src="http://conecode.com/news/wp-content/uploads/2013/03/Show-Editor-and-H-300x209.png" width="300" height="209" /></a></p>
<p><span style="color: #ff0000;">12.</span> While holding down the &#8220;control&#8221; button, <strong>drag the Label</strong> from your Storyboard to just underneath your viewWeb @property:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Drag-Label-to-H.png"><img class="aligncenter size-medium wp-image-666" alt="Drag Label to H" src="http://conecode.com/news/wp-content/uploads/2013/03/Drag-Label-to-H-300x170.png" width="300" height="170" /></a></p>
<p><span style="color: #ff0000;">13.</span> Name this Outlet <strong>labelLoading</strong> and click <strong>Connect</strong>:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/labeLoading-Connect.png"><img class="aligncenter size-full wp-image-671" alt="labeLoading Connect" src="http://conecode.com/news/wp-content/uploads/2013/03/labeLoading-Connect.png" width="273" height="155" /></a></p>
<p>You&#8217;ll notice that a new @property line is automatically created.</p>
<p><span style="color: #ff0000;">NOTE: If you also have an iPad Storyboard, repeat steps 2 through 11 for the that storyboard. However, for step 12, you&#8217;ll want to drag the label to the existing labelLoading @property line.</span></p>
<p><span style="color: #ff0000;">14.</span> Change you <strong>Editor</strong> and <strong>View</strong> buttons to the following:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Editor-View-3.png"><img class="aligncenter size-full wp-image-669" alt="Editor View 3" src="http://conecode.com/news/wp-content/uploads/2013/03/Editor-View-3.png" width="216" height="48" /></a></p>
<p><span style="color: #ff0000;">15.</span> In the file sidebar to the left, click on <strong>ViewController.h</strong>:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Click-View-Controller-H-file.png"><img class="aligncenter size-medium wp-image-680" alt="Click View Controller H file" src="http://conecode.com/news/wp-content/uploads/2013/03/Click-View-Controller-H-file-300x273.png" width="300" height="273" /></a></p>
<p><span style="color: #ff0000;">16.</span> Add the following piece code to the end of the @interface line:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="sy0">&amp;</span>lt;UIWebViewDelegate<span class="sy0">&amp;</span>gt;</pre></div></div></div></div></div></div></div>


<p>This gives us more access the the web view.</p>
<p><span style="color: #ff0000;">17.</span> In the file sidebar, click on <strong>ViewController.m</strong>:</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2011/05/Screen-Shot-2012-08-21-at-3.45.43-PM1.png"><img class="aligncenter size-full wp-image-648" alt="Click on ViewController.m" src="http://conecode.com/news/wp-content/uploads/2011/05/Screen-Shot-2012-08-21-at-3.45.43-PM1.png" width="258" height="210" /></a></p>
<p><span style="color: #ff0000;">18.</span> Make sure the following line is near the top under the existing viewWeb @synthesize line (it may be there already):</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="re0">@synthesize</span> labelLoading;</pre></div></div></div></div></div></div></div>


<p><span style="color: #ff0000;">19.</span> Inside the <strong>viewDidLoad</strong> method add the following line to the top:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="br0">&#91;</span>viewWeb setDelegate:self<span class="br0">&#93;</span>;</pre></div></div></div></div></div></div></div>


<p>This is needed for the code in the next step to work.</p>
<p><span style="color: #ff0000;">20.</span> Add the following 2 methods under the viewDidLoad method:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span>void<span class="br0">&#41;</span>webViewDidStartLoad:<span class="br0">&#40;</span>UIWebView <span class="sy0">*</span><span class="br0">&#41;</span>webView <span class="br0">&#123;</span>
    <span class="br0">&#91;</span>labelLoading setHidden:<span class="kw1">NO</span><span class="br0">&#93;</span>;
<span class="br0">&#125;</span>
&nbsp;
<span class="sy0">-</span> <span class="br0">&#40;</span>void<span class="br0">&#41;</span>webViewDidFinishLoad:<span class="br0">&#40;</span>UIWebView <span class="sy0">*</span><span class="br0">&#41;</span>webView <span class="br0">&#123;</span>
    <span class="br0">&#91;</span>labelLoading setHidden:<span class="kw1">YES</span><span class="br0">&#93;</span>;
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>The first method runs as soon as the page starts loading (making the label visible). The second runs when the page is done (hiding the label).</p>
<p>You are now ready to run the app!</p>
<p><a href="http://conecode.com/news/wp-content/uploads/2013/03/Finished-ScreenShot.png"><img class="aligncenter size-medium wp-image-667" alt="Finished ScreenShot" src="http://conecode.com/news/wp-content/uploads/2013/03/Finished-ScreenShot-201x300.png" width="201" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2013/03/ios-how-to-adding-a-loading-label-to-a-uiwebview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Rate A Purchased iPhone App</title>
		<link>http://conecode.com/news/2012/07/rate-a-purchased-iphone-app/</link>
		<comments>http://conecode.com/news/2012/07/rate-a-purchased-iphone-app/#comments</comments>
		<pubDate>Thu, 05 Jul 2012 22:52:27 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Quick Tip]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=625</guid>
		<description><![CDATA[I was recently asked how to rate a purchased iPhone app and it&#8217;s a bit of a process so I thought I would list the steps here. Open the App Store app on your iPhone. Tap the Updates button on &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/07/rate-a-purchased-iphone-app/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p>I was recently asked how to rate a purchased iPhone app and it&#8217;s a bit of a process so I thought I would list the steps here.</p>
<ol>
<li>Open the App Store app on your iPhone.</li>
<li>Tap the Updates button on the tab bar at the bottom of the screen.</li>
<li>Tap the &#8220;Purchased&#8221; row at the top of the table.</li>
<li>Scroll down to find the app you want to rate.  For example <a title="Solitaire Poker App" href="http://itunes.apple.com/us/app/solitaire-poker/id464306726?mt=8" target="_blank">Solitaire Poker</a>.</li>
<li>Scroll down and tap the Ratings button.  It might be labeled &#8220;No Ratings&#8221; or &#8220;155 Ratings&#8221; or something similar.</li>
<li>Finally, tap &#8220;Write a Review&#8221;</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/07/rate-a-purchased-iphone-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS How To &#8211; Using the Proximity Sensor</title>
		<link>http://conecode.com/news/2012/06/ios-how-to-using-the-proximity-sensor/</link>
		<comments>http://conecode.com/news/2012/06/ios-how-to-using-the-proximity-sensor/#comments</comments>
		<pubDate>Fri, 22 Jun 2012 18:20:38 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iOS App Development for Beginners]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Quick Tip]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=610</guid>
		<description><![CDATA[If you&#8217;re going to create an app that plays audio, one great feature to have is the ability for the user to be able to listen to the audio through the headset of the device (when they put it to &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/06/ios-how-to-using-the-proximity-sensor/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re going to create an app that plays audio, one great feature to have is the ability for the user to be able to listen to the audio through the headset of the device (when they put it to their head) rather than the speaker at the bottom. Doing so is fairly simple. I recommend reading <a title="iOS How To – Playing Audio" href="http://conecode.com/news/2012/06/ios-how-to-playing-audio/" target="_blank">iOS How To &#8211; Playing Audio</a> before continuing.<span id="more-610"></span></p>
<p>First, in your viewDidLoad method add:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="sy0">//</span> Proximity Sensor Notification
        <span class="br0">&#91;</span><span class="br0">&#91;</span>NSNotificationCenter defaultCenter<span class="br0">&#93;</span> addObserver:self selector:<span class="re0">@selector</span><span class="br0">&#40;</span>proximityChanged:<span class="br0">&#41;</span> <span class="kw1">name</span>:@<span class="st0">&quot;UIDeviceProximityStateDidChangeNotification&quot;</span> object:device<span class="br0">&#93;</span>;</pre></div></div></div></div></div></div></div>


<p>This will create an observer that checks for a change in proximity.</p>
<p>Second, add the following code to the method that will be playing the audio:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1">UIDevice <span class="sy0">*</span>device <span class="sy0">=</span> <span class="br0">&#91;</span>UIDevice currentDevice<span class="br0">&#93;</span>;
        device.proximityMonitoringEnabled <span class="sy0">=</span> <span class="kw1">YES</span>;</pre></div></div></div></div></div></div></div>


<p>This will enable the proximity monitoring.</p>
<p>Third, add the following method:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span>void<span class="br0">&#41;</span>proximityChanged:<span class="br0">&#40;</span>NSNotification <span class="sy0">*</span><span class="br0">&#41;</span>notification <span class="br0">&#123;</span>
	UIDevice <span class="sy0">*</span>device <span class="sy0">=</span> <span class="br0">&#91;</span>notification object<span class="br0">&#93;</span>;
    <span class="kw3">if</span> <span class="br0">&#40;</span>device.proximityState <span class="sy0">==</span> <span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="br0">&#91;</span>audioSession setCategory:AVAudioSessionCategoryPlayAndRecord <span class="kw3">error</span>:nil<span class="br0">&#93;</span>;
    <span class="br0">&#125;</span> <span class="kw3">else</span> <span class="br0">&#123;</span>
        <span class="br0">&#91;</span>audioSession setCategory:AVAudioSessionCategoryPlayback <span class="kw3">error</span>:nil<span class="br0">&#93;</span>;
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>This checks the proximity state and then redirects the audio in real time to the correct output hardware.</p>
<p>It&#8217;s also a good idea to disable proximity monitoring when audio is no longer being played. In your manual stopAudio method or IF statement and in the delegate audioPlayerDidFinishPlaying method, add the follow code:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1">UIDevice <span class="sy0">*</span>device <span class="sy0">=</span> <span class="br0">&#91;</span>UIDevice currentDevice<span class="br0">&#93;</span>;
    device.proximityMonitoringEnabled <span class="sy0">=</span> <span class="kw1">NO</span>;</pre></div></div></div></div></div></div></div>


]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/06/ios-how-to-using-the-proximity-sensor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iOS How To &#8211; Playing Audio</title>
		<link>http://conecode.com/news/2012/06/ios-how-to-playing-audio/</link>
		<comments>http://conecode.com/news/2012/06/ios-how-to-playing-audio/#comments</comments>
		<pubDate>Fri, 22 Jun 2012 18:19:10 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Quick Tip]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Xcode 4]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=612</guid>
		<description><![CDATA[If you have audio that you would like the user to manually control with a button, this is the quick How To for you. The end result will allow you to play and stop audio with the same button. In future &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/06/ios-how-to-playing-audio/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p>If you have audio that you would like the user to manually control with a button, this is the quick <a title="How To" href="http://conecode.com/news/category/how-to/" target="_blank">How To</a> for you. The end result will allow you to play and stop audio with the same button. In future posts, I will show how to reroute that played audio from speaker to headset using the <a title="iOS How To – Using the Proximity Sensor" href="http://conecode.com/news/2012/06/ios-how-to-using-the-proximity-sensor/" target="_blank">proximity sensor</a> and bluetooth headset.<span id="more-612"></span></p>
<p>So before we do any code, we want to add the AVFoundation and AudioToolbox frameworks. Also copy the audio file you&#8217;d like to play into your project.</p>
<p>Now let&#8217;s code.</p>
<p>This is basically what your .h file should look like:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1">#import
#import 
&nbsp;
<span class="re0">@interface</span> ViewController : UIViewController  <span class="br0">&#123;</span>
    AVAudioPlayer <span class="sy0">*</span>audioPlayer;
    AVAudioSession <span class="sy0">*</span>audioSession;
<span class="br0">&#125;</span>
&nbsp;
@<span class="kw3">property</span> <span class="br0">&#40;</span>strong, nonatomic<span class="br0">&#41;</span> IBOutlet UIButton <span class="sy0">*</span>buttonControl;
&nbsp;
<span class="sy0">-</span> <span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>playAudio:<span class="br0">&#40;</span>UIButton <span class="sy0">*</span><span class="br0">&#41;</span>button;
&nbsp;
@<span class="kw3">end</span></pre></div></div></div></div></div></div></div>


<p>Now to the .m file. Add this to the viewDidLoad method:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1">    audioSession <span class="sy0">=</span> <span class="br0">&#91;</span>AVAudioSession sharedInstance<span class="br0">&#93;</span>;
    NSError <span class="sy0">*</span><span class="kw3">error</span>;
    <span class="sy0">//</span> This will send <span class="kw2">the</span> audio <span class="kw3">to</span> <span class="kw2">the</span> speaker. <span class="kw3">If</span> you just want <span class="kw2">the</span> audio <span class="kw3">to</span> go <span class="kw3">to</span> <span class="kw2">the</span> headset, change <span class="kw2">the</span> Category <span class="kw3">to</span> AVAudioSessionCategoryPlayAndRecord
    <span class="br0">&#91;</span>audioSession setCategory:AVAudioSessionCategoryPlayback <span class="kw3">error</span>:<span class="sy0">&amp;</span>amp;<span class="kw3">error</span><span class="br0">&#93;</span>;
	<span class="br0">&#91;</span>audioSession setActive:<span class="kw1">YES</span> <span class="kw3">error</span>:<span class="sy0">&amp;</span>amp;<span class="kw3">error</span><span class="br0">&#93;</span>;
&nbsp;
    NSString <span class="sy0">*</span>path <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>NSBundle mainBundle<span class="br0">&#93;</span> pathForResource:@<span class="st0">&quot;myAudio&quot;</span> ofType:@<span class="st0">&quot;mp3&quot;</span><span class="br0">&#93;</span>;
    audioPlayer <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>AVAudioPlayer alloc<span class="br0">&#93;</span> initWithContentsOfURL:<span class="br0">&#91;</span>NSURL fileURLWithPath:path<span class="br0">&#93;</span> <span class="kw3">error</span>:NULL<span class="br0">&#93;</span>;
    audioPlayer.delegate <span class="sy0">=</span> self;
    <span class="br0">&#91;</span>audioPlayer prepareToPlay<span class="br0">&#93;</span>;</pre></div></div></div></div></div></div></div>


<p>Next, add the following 2 methods:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>playAudio:<span class="br0">&#40;</span>UIButton <span class="sy0">*</span><span class="br0">&#41;</span>button <span class="br0">&#123;</span>
    <span class="kw3">if</span> <span class="br0">&#40;</span><span class="br0">&#91;</span>button.titleLabel.<span class="kw1">text</span> isEqualToString:@<span class="st0">&quot;Play&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="br0">&#91;</span>button setTitle:@<span class="st0">&quot;Stop&quot;</span> forState:UIControlStateNormal<span class="br0">&#93;</span>;
        <span class="br0">&#91;</span>audioPlayer play<span class="br0">&#93;</span>;
    <span class="br0">&#125;</span> <span class="kw3">else</span> <span class="br0">&#123;</span>
        <span class="br0">&#91;</span>button setTitle:@<span class="st0">&quot;Play&quot;</span> forState:UIControlStateNormal<span class="br0">&#93;</span>;
        <span class="br0">&#91;</span>audioPlayer stop<span class="br0">&#93;</span>;
&nbsp;
        <span class="sy0">//</span> This will reset <span class="kw2">the</span> audio <span class="kw2">back</span> <span class="kw3">to</span> <span class="kw2">the</span> <span class="kw2">beginning</span>. <span class="kw2">Not</span> doing this will just pause <span class="kw2">the</span> audio.
        audioPlayer.currentTime <span class="sy0">=</span> <span class="nu0">0</span>;
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="sy0">-</span> <span class="br0">&#40;</span>void<span class="br0">&#41;</span>audioPlayerDidFinishPlaying:<span class="br0">&#40;</span>AVAudioPlayer <span class="sy0">*</span><span class="br0">&#41;</span>player successfully:<span class="br0">&#40;</span>BOOL<span class="br0">&#41;</span>flag <span class="br0">&#123;</span>
    <span class="br0">&#91;</span>buttonControl setTitle:@<span class="st0">&quot;Play&quot;</span> forState:UIControlStateNormal<span class="br0">&#93;</span>;
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Finally, in the xib file create your button and link it to buttonControl and the playAudio method.</p>
]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/06/ios-how-to-playing-audio/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iOS How To &#8211; Create A Grid of UIButtons</title>
		<link>http://conecode.com/news/2012/05/ios-how-to-create-a-grid-of-uibuttons/</link>
		<comments>http://conecode.com/news/2012/05/ios-how-to-create-a-grid-of-uibuttons/#comments</comments>
		<pubDate>Thu, 24 May 2012 16:30:50 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Quick Tip]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Xcode 4]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=604</guid>
		<description><![CDATA[When we created our games Memory Gizmo Words, Memory Gizmo Math and Solitaire Poker, we needed to layout the game board into a grid of rows and columns. It was fairly simple and we&#8217;ll tell you how we did it. &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/05/ios-how-to-create-a-grid-of-uibuttons/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p>When we created our games <a title="Memory Gizmo Words" href="http://itunes.apple.com/us/app/memory-gizmo-words/id452809584?mt=8">Memory Gizmo Words</a>, <a title="Memory Gizmo Math" href="http://itunes.apple.com/us/app/memory-gizmo-math/id457777326?mt=8">Memory Gizmo Math</a> and <a title="Solitaire Poker" href="http://itunes.apple.com/us/app/solitaire-poker/id464306726?mt=8">Solitaire Poker</a>, we needed to layout the game board into a grid of rows and columns. It was fairly simple and we&#8217;ll tell you how we did it.<span id="more-604"></span></p>
<p>First we add this to the .H file:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1">#define kButtonColumns <span class="nu0">4</span>
#define kButtonRows <span class="nu0">4</span>
&nbsp;
<span class="re0">@interface</span> GameViewController <span class="br0">&#123;</span>
    UIButton <span class="sy0">*</span><span class="kw1">buttons</span><span class="br0">&#91;</span>kButtonColumns<span class="br0">&#93;</span><span class="br0">&#91;</span>kButtonRows<span class="br0">&#93;</span>;    
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>This you put this into you .M file:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="sy0">-</span> <span class="br0">&#40;</span>void<span class="br0">&#41;</span>placeTiles
<span class="br0">&#123;</span>
    NSInteger intTagNumber  <span class="sy0">=</span> <span class="nu0">0</span>;
    NSInteger intLeftMargin <span class="sy0">=</span> <span class="nu0">11</span>; <span class="sy0">//</span> horizontal offset <span class="kw3">from</span> <span class="kw2">the</span> edge <span class="kw3">of</span> <span class="kw2">the</span> screen
    NSInteger intTopMargin  <span class="sy0">=</span> <span class="nu0">58</span>; <span class="sy0">//</span> vertical offset <span class="kw3">from</span> <span class="kw2">the</span> edge <span class="kw3">of</span> <span class="kw2">the</span> screen
    NSInteger intXSpacing   <span class="sy0">=</span> <span class="nu0">78</span>; <span class="sy0">//</span> <span class="kw1">number</span> <span class="kw3">of</span> pixels <span class="kw1">between</span> <span class="kw2">the</span> button origins <span class="br0">&#40;</span>horizontally<span class="br0">&#41;</span>
    NSInteger intYSpacing   <span class="sy0">=</span> <span class="nu0">77</span>; <span class="sy0">//</span> <span class="kw1">number</span> <span class="kw3">of</span> pixels <span class="kw1">between</span> <span class="kw2">the</span> button origins <span class="br0">&#40;</span>vertically<span class="br0">&#41;</span>
    NSInteger intXTile;
    NSInteger intYTile;
&nbsp;
    for <span class="br0">&#40;</span>int y <span class="sy0">=</span> <span class="nu0">0</span>; y <span class="sy0">&amp;</span>lt; kButtonRows; y<span class="sy0">++</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        for <span class="br0">&#40;</span>int x <span class="sy0">=</span> <span class="nu0">0</span>; x <span class="sy0">&amp;</span>lt; kButtonColumns; x<span class="sy0">++</span><span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
&nbsp;
            intXTile <span class="sy0">=</span> <span class="br0">&#40;</span>x <span class="sy0">*</span> intXSpacing<span class="br0">&#41;</span> <span class="sy0">+</span> intLeftMargin;
            intYTile <span class="sy0">=</span> <span class="br0">&#40;</span>y <span class="sy0">*</span> intYSpacing<span class="br0">&#41;</span> <span class="sy0">+</span> intTopMargin;
&nbsp;
            <span class="sy0">//</span> create a value button, <span class="kw1">text</span>, <span class="kw2">or</span> image
            <span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UIButton alloc<span class="br0">&#93;</span> initWithFrame:CGRectMake<span class="br0">&#40;</span>intXTile, intYTile, <span class="nu0">58</span>, <span class="nu0">58</span><span class="br0">&#41;</span><span class="br0">&#93;</span>;
            <span class="br0">&#91;</span><span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span> setBackgroundImage:<span class="br0">&#91;</span>UIImage imageNamed:@<span class="st0">&quot;spinTile01&quot;</span><span class="br0">&#93;</span> forState:UIControlStateNormal<span class="br0">&#93;</span>;
            <span class="br0">&#91;</span><span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span> addTarget:self action:<span class="re0">@selector</span><span class="br0">&#40;</span>actionPick:<span class="br0">&#41;</span> forControlEvents:UIControlEventTouchDown<span class="br0">&#93;</span>;
            <span class="br0">&#91;</span><span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span> setTitleColor:<span class="br0">&#91;</span>UIColor colorWithRed:<span class="nu0">0</span><span class="sy0">/</span><span class="nu0">255.0</span> green:<span class="nu0">0</span><span class="sy0">/</span><span class="nu0">255.0</span> blue:<span class="nu0">92</span><span class="sy0">/</span><span class="nu0">255.0</span> alpha:<span class="nu0">1</span><span class="br0">&#93;</span> forState:UIControlStateNormal<span class="br0">&#93;</span>;
            <span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span>.titleLabel.font <span class="sy0">=</span> <span class="br0">&#91;</span>UIFont fontWithName:@<span class="st0">&quot;TrebuchetMS-Bold&quot;</span> size:<span class="nu0">42</span><span class="br0">&#93;</span>;
            <span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span>.adjustsImageWhenHighlighted <span class="sy0">=</span> <span class="kw1">NO</span>;
            <span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span>.adjustsImageWhenDisabled <span class="sy0">=</span> <span class="kw1">NO</span>;
            <span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span>.tag <span class="sy0">=</span> intTagNumber;
            <span class="br0">&#91;</span>self.view addSubview:<span class="kw1">buttons</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#91;</span>y<span class="br0">&#93;</span><span class="br0">&#93;</span>;
&nbsp;
            intTagNumber<span class="sy0">++</span>;
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="sy0">-</span> <span class="br0">&#40;</span>IBAction<span class="br0">&#41;</span>actionPick:<span class="br0">&#40;</span><span class="kw1">id</span><span class="br0">&#41;</span>sender 
<span class="br0">&#123;</span>
    UIButton <span class="sy0">*</span>button <span class="sy0">=</span> <span class="br0">&#40;</span>UIButton <span class="sy0">*</span><span class="br0">&#41;</span>sender;    
    NSLog<span class="br0">&#40;</span>@<span class="st0">&quot;Button tag: %i&quot;</span>, button.tag<span class="br0">&#41;</span>;
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Then in your viewDidLoad just run the placeTiles method:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="br0">&#91;</span>self placeTiles<span class="br0">&#93;</span>;</pre></div></div></div></div></div></div></div>


]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/05/ios-how-to-create-a-grid-of-uibuttons/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Xcode 4 How To &#8211; Exclude A File From ARC</title>
		<link>http://conecode.com/news/2012/05/xcode-4-how-to-exclude-a-file-from-arc/</link>
		<comments>http://conecode.com/news/2012/05/xcode-4-how-to-exclude-a-file-from-arc/#comments</comments>
		<pubDate>Sat, 12 May 2012 18:02:05 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Quick Tip]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Xcode 4]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=601</guid>
		<description><![CDATA[ARC (Automatic Reference Counting) is great addition to Xcode 4. It saves you time and aggravation of releasing objects from memory. However, there may be several libraries out there that have not been converted to ARC that you would like to inclue &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/05/xcode-4-how-to-exclude-a-file-from-arc/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p>ARC (Automatic Reference Counting) is great addition to Xcode 4. It saves you time and aggravation of releasing objects from memory. However, there may be several libraries out there that have not been converted to ARC that you would like to inclue in your project. Rather than going through each file an converting it yourself, there is a way to exclude those file from ARC.<span id="more-601"></span></p>
<ol>
<li><strong>Click on the Target</strong></li>
<li><strong>Click on Build Phases</strong></li>
<li><strong>Open the Compile Sources section</strong></li>
<li><strong>Find file you want to exclude and double click on it.</strong></li>
<li><strong>Enter the following in to the dialog box -fno-objc-arc and click Done</strong></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/05/xcode-4-how-to-exclude-a-file-from-arc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS5 How To: JSON to NSDictionary &#8211; NSJsonSerialization</title>
		<link>http://conecode.com/news/2012/05/ios5-how-to-json-to-nsdictionary-nsjsonserialization/</link>
		<comments>http://conecode.com/news/2012/05/ios5-how-to-json-to-nsdictionary-nsjsonserialization/#comments</comments>
		<pubDate>Fri, 11 May 2012 17:05:16 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Quick Tip]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Xcode 4]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=592</guid>
		<description><![CDATA[iOS5 came with several shortcuts to parse JSON without the need of third-party libraries. It&#8217;s called NSJsonSerialization, and here&#8217;s how it works. Let&#8217;s say you&#8217;ve received JSON data (we&#8217;ll call it responseData) from a url and you would like to convert &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/05/ios5-how-to-json-to-nsdictionary-nsjsonserialization/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p>iOS5 came with several shortcuts to parse JSON without the need of third-party libraries. It&#8217;s called NSJsonSerialization, and here&#8217;s how it works.</p>
<p>Let&#8217;s say you&#8217;ve received JSON data (we&#8217;ll call it responseData) from a url and you would like to convert the JSON to an NSDictionary  (dictJSON). Just put in the following code:<span id="more-592"></span></p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1">NSError <span class="sy0">*</span><span class="kw3">error</span> <span class="sy0">=</span> nil;
NSDictionary <span class="sy0">*</span>dictJSON <span class="sy0">=</span> <span class="br0">&#91;</span>NSJSONSerialization JSONObjectWithData:responseData options:<span class="nu0">0</span> <span class="kw3">error</span>:<span class="sy0">&amp;</span>amp;<span class="kw3">error</span><span class="br0">&#93;</span>;
&nbsp;
<span class="kw3">if</span> <span class="br0">&#40;</span><span class="kw3">error</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
    NSLog<span class="br0">&#40;</span>@<span class="st0">&quot;JSON parse error: %@&quot;</span>, <span class="br0">&#91;</span><span class="kw3">error</span> localizedDescription<span class="br0">&#93;</span><span class="br0">&#41;</span>;
    <span class="kw3">return</span>;
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/05/ios5-how-to-json-to-nsdictionary-nsjsonserialization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OSX How To &#8211; View The NSDocumentDirectory Using Finder</title>
		<link>http://conecode.com/news/2012/05/view-the-nsdocumentdirectory-using-finder/</link>
		<comments>http://conecode.com/news/2012/05/view-the-nsdocumentdirectory-using-finder/#comments</comments>
		<pubDate>Fri, 04 May 2012 21:24:14 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iOS App Development for Beginners]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Xcode 4]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=584</guid>
		<description><![CDATA[This morning I was working on an iOS app that required saving various files to the device.  I wanted to track these files while running the iPhone Simulator to make sure my code was handling the files as it was &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/05/view-the-nsdocumentdirectory-using-finder/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p><a href="http://conecode.com/news/wp-content/uploads/2012/05/AppleScript.png"><img class="alignleft size-full wp-image-587" title="AppleScript" src="http://conecode.com/news/wp-content/uploads/2012/05/AppleScript.png" alt="" width="200" height="200" /></a>This morning I was working on an iOS app that required saving various files to the device.  I wanted to track these files while running the iPhone Simulator to make sure my code was handling the files as it was supposed to.  To do this I could dig through the folder structure in Terminal or output a bunch of NSLogs with the data I wanted, but the easiest method would be to open Finder and watch the directory as changes were made.  Since I know this will come up again in the future, I decided to make an AppleScript that will help me Quickly navigate to the iPhone Simulator path. Below are the steps I used to create the script.<span id="more-584"></span></p>
<p>Begin by opening the AppleScript Editor.  Press Command + Spacebar to open Spotlight, type &#8220;AppleScript&#8221;, and then press Enter.</p>
<p>Next, enter the following code into the editor.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="applescript"><pre class="de1"><span class="kw3">tell</span> <span class="kw1">application</span> <span class="st0">&quot;Finder&quot;</span>
	<span class="kw1">activate</span>
	<span class="kw3">set</span> x <span class="kw3">to</span> <span class="br0">&#40;</span><span class="kw1">path to</span> home <span class="kw1">folder</span> <span class="kw2">as</span> <span class="kw1">text</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp; <span class="st0">&quot;Library:Application Support:iPhone Simulator:5.1:Applications&quot;</span> <span class="kw2">as</span> <span class="kw1">alias</span>
	<span class="kw1">open</span> x
<span class="kw3">end</span> <span class="kw3">tell</span></pre></div></div></div></div></div></div></div>


<p>This script will open a Finder window to the Applications folder for the iPhone Simulator version 5.1.  You can run the script now by clicking the Run button to see it work, but to make it so we can easily run it again later, we should save the file.</p>
<ol>
<li>Go to the menu and choose File &gt; Save As.</li>
<li>Enter a name for the script.  I entered &#8220;Open Simulator Folder&#8221;.</li>
<li>For where to save the files, I chose my Applications folder.</li>
<li>Choose Application for the file format.</li>
<li>And Finally Click the Save button.</li>
</ol>
<p>Now, if you go to your Launchpad, you should be able to find the script and click on it to run it.</p>
<p>The Applications folder stores each of your apps in a folder with a long encrypted name, but you can usually determine which app you want by looking at the Modified date.  Once you open the folder containing your app, you&#8217;ll see a file with the name of the app and a Documents folder.  You can then double click on the Documents folder to view all the files your app has saved to the NSDocumentDirectory.</p>
]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/05/view-the-nsdocumentdirectory-using-finder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS How To: Accessing iPhone Simulator&#8217;s SQLite</title>
		<link>http://conecode.com/news/2012/05/ios-how-to-accessing-iphone-simulators-sqlite/</link>
		<comments>http://conecode.com/news/2012/05/ios-how-to-accessing-iphone-simulators-sqlite/#comments</comments>
		<pubDate>Fri, 04 May 2012 17:51:02 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Quick Tip]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Xcode 4]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=574</guid>
		<description><![CDATA[When working with Core Data or SQLite, you never know if what your saving to your database is actually saving. Well if you&#8217;re testing with iPhone Simulator you can. Run your test that is supposed to be saving data then &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/05/ios-how-to-accessing-iphone-simulators-sqlite/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p>When working with Core Data or SQLite, you never know if what your saving to your database is actually saving. Well if you&#8217;re testing with iPhone Simulator you can. Run your test that is supposed to be saving data then do the following:<br />
<span id="more-574"></span><br />
In Terminal go to the following location.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1"><span class="sy0">/</span>Users<span class="sy0">/&lt;</span>your name<span class="sy0">&gt;/</span>Library<span class="sy0">/</span>Application Support<span class="sy0">/</span>iPhone Simulator<span class="sy0">/&lt;</span>version<span class="sy0">&gt;/</span>Applications<span class="sy0">/&lt;</span>app name<span class="sy0">&gt;/</span>Documents</pre></div></div></div></div></div></div></div>


<p>&nbsp;</p>
<p>Type sqlite3 followed by the name of the sqlite file.</p>
<pre>sqlite3 myfile.sqlite</pre>
<p>&nbsp;</p>
<p>Now type .help to see a list of commands or type out straight sql</p>
<pre>select * from entityname</pre>
<p>&nbsp;</p>
<p>To exit sqlite3 type</p>
<pre>.exit</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/05/ios-how-to-accessing-iphone-simulators-sqlite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS How To: Check if Application is Active</title>
		<link>http://conecode.com/news/2012/05/ios-how-to-check-if-application-is-active/</link>
		<comments>http://conecode.com/news/2012/05/ios-how-to-check-if-application-is-active/#comments</comments>
		<pubDate>Tue, 01 May 2012 18:29:40 +0000</pubDate>
		<dc:creator>Cone Code Team</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[Quick Tip]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Xcode 4]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPod touch]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://conecode.com/news/?p=566</guid>
		<description><![CDATA[Have you ever wanted to know when your app entered the background or came back into the foreground? But you don&#8217;t want to have to hassle with trying to run methods in your current view from the App Delegate? I &#8230; <div class="readmore"><a href="http://conecode.com/news/2012/05/ios-how-to-check-if-application-is-active/">Continue reading <span class="meta-nav"></span></a></div>]]></description>
				<content:encoded><![CDATA[<p>Have you ever wanted to know when your app entered the background or came back into the foreground? But you don&#8217;t want to have to hassle with trying to run methods in your current view from the App Delegate? I can ease your pain. Add the following code to the viewDidLoad method of the class you like to handle these events:<span id="more-566"></span></p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="objc"><pre class="de1"><span class="co2">// check if app is in the background</span>
<span class="br0">&#91;</span><span class="br0">&#91;</span><span class="kw5">NSNotificationCenter</span> defaultCenter<span class="br0">&#93;</span> addObserver<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;EnteredBackground&quot;</span> selector<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>appDidEnterBackground<span class="br0">&#41;</span> name<span class="sy0">:</span>UIApplicationDidEnterBackgroundNotification object<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;
&nbsp;
<span class="co2">// check if app is in the foreground</span>
<span class="br0">&#91;</span><span class="br0">&#91;</span><span class="kw5">NSNotificationCenter</span> defaultCenter<span class="br0">&#93;</span> addObserver<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;EnteredForeground&quot;</span> selector<span class="sy0">:</span><span class="kw1">@selector</span><span class="br0">&#40;</span>appDidEnterForeground<span class="br0">&#41;</span> name<span class="sy0">:</span>UIApplicationDidBecomeActiveNotification object<span class="sy0">:</span><span class="kw2">nil</span><span class="br0">&#93;</span>;</pre></div></div></div></div></div></div></div>


<p>The first one will run the appDidEnterBackground method when the app has, indeed, entered the background.<br />
The second does the same for entering the foreground.</p>
]]></content:encoded>
			<wfw:commentRss>http://conecode.com/news/2012/05/ios-how-to-check-if-application-is-active/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
