<?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>Mobile Perspectives &#187; iPhone Dev Tools</title>
	<atom:link href="http://www.BluMtnWerx.com/blog/tag/iphone-dev-tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.BluMtnWerx.com/blog</link>
	<description>Computing at the Edge!</description>
	<lastBuildDate>Tue, 27 Jul 2010 23:43:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Chipmunk:  2D Physics on the iPhone</title>
		<link>http://www.BluMtnWerx.com/blog/2009/07/chipmunk-2d-physics-on-the-iphone/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/07/chipmunk-2d-physics-on-the-iphone/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 19:43:22 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[2D Physics]]></category>
		<category><![CDATA[Chipmunk]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=205</guid>
		<description><![CDATA[We recently submitted v1.1 of iPuck to the App Store.&#160;  The primary "under the hood" change was a port to the Chipmunk physics library.&#160;  If you need a lightweight, fast and straightforward physics library for 2D apps on the iPhone, you should check Chipmunk out.&#160;  In this discussion, we'll introduce the library and talk a bit about our experience with it.]]></description>
			<content:encoded><![CDATA[<p>We wanted to support much more interesting gameplay, along with a more accurate physics simulation, in the first significant update to <a href="http://www.blumtnwerx.com/iPuck.html" title="iPuck web page">iPuck</a>.&nbsp;  Unfortunately, this forced us to swap out the simulation engine used in v1.0.&nbsp;  The old library worked fine, but it couldn&#8217;t be easily extended to meet the new requirements.&nbsp;  I looked at some of the 3D packages (One that I considered pretty carefully was <a href="http://www.bulletphysics.com/wordpress/" title="Bullet Physics Library web page">Bullet</a>, which is bundled with <a href="http://www.oolongengine.com/" title="Oolong web page">Oolong</a>, the package that <a href="http://www.blumtnwerx.com/BMWTeam.html" title="Paul Stoaks, BluMtnWerx">Paul</a> used for <a href="http://www.blumtnwerx.com/iPunt.html" title="iPunt web page">iPunt</a>).&nbsp;  However, the 3D libraries all seemed to be overkill for iPuck.&nbsp;  Besides, I would feel bad about wasting the Z axis.&nbsp;  One 2D package kept turning up in my searches&mdash;<strong><a href="http://code.google.com/p/chipmunk-physics/" title="Chipmunk Physics website">chipmunk-physics</a></strong> (another <a href="http://wiki.slembcke.net/main/published/Chipmunk" title="Chipmunk Physics wiki">wiki page</a> is also available, but I think that the <a href="http://code.google.com/p/chipmunk-physics/" title="Chipmunk Physics project Page">code.google.com page</a> is more up-to-date).  <a href="http://code.google.com/p/chipmunk-physics/" title="chipmunk-physics"><img style="float: right; margin: 0.2em;" src="http://files.slembcke.net/chipmunk/logo/logo1_small.png" alt="chipmunk-physics logo"/></a>.</p>
<p>Chipmunk is a</p>
<blockquote><p><em>Fast and lightweight 2D rigid body physics library in C</em></p></blockquote>
<p>That last bit is important for iPhone development, because, as we all know, &#8216;C&#8217; plays very well with Objective-C.&nbsp;  Once I figured out how to call Objective-C methods from the Chipmunk related &#8216;C&#8217; code, integration was very smooth.&nbsp;  It&#8217;s worth mentioning that the standard &#8216;C&#8217; code in the Chipmunk distribution compiles fine in Xcode and runs with no problems on the iPhone and iPod touch.&nbsp;  I was worried that I might run into some issues, but it was perfect.&nbsp;  By the way, we plan to use Chipmunk for other projects, so I set it up as a &#8220;Source Tree&#8221; in Xcode, rather than just dumping the files directly into the iPuck project space.&nbsp;  Paul wrote an excellent <a href="http://www.blumtnwerx.com/blog/2009/04/xcode-workspace-setup-for-oolong/" title="Mobile Perspectives:  Xcode Workspace Setup for Oolong">post</a> on doing this for Oolong.&nbsp;  I just followed his directions.</p>
<p>I won&#8217;t list all of Chipmunk&#8217;s features, they are nicely presented on the <a href="http://code.google.com/p/chipmunk-physics/" title="Chipmunk Physics project Page">project page</a>, but it is fast and straightforward to use.</p>
<p>The <a href="http://code.google.com/p/chipmunk-physics/wiki/Documentation" title="Chipmunk Documentation">documentation</a> is a bit sparse, especially for someone just getting started.&nbsp;  The demos are very helpful, but generally seem to assume that we already have a pretty good understanding of Chipmunk.&nbsp;  A set of demo programs is bundled with the <a href="http://files.slembcke.net/chipmunk/release/ChipmunkLatest.tgz" title="Current Chipmunk distribution">ChipmunkLatest.tgz</a> download.&nbsp;  Even nicer demo programs are available in the <a href="http://code.google.com/p/chipmunk-physics/source/browse/" title="Chipmunk SVN Repository">project repository</a>.&nbsp;  </p>
<p>Fortunately, <a href="http://www.alexandre-gomes.com/?page_id=2" title="About Alexandre Gomes">Alexandre Gomes</a> has prepared a <a href="http://www.alexandre-gomes.com/articles/chipmunk/" title="alexandre gomes:  Getting Started with Chipmunk">nice tutorial</a> on getting started with Chipmunk.&nbsp;  I noticed a few typos in the sample code, but it gave me a great start towards learning the library and figuring out how to slide it on to the iPuck chassis.&nbsp;  Mr. Gomes does a good job of explaining the <a href="http://www.alexandre-gomes.com/articles/chipmunk/basicconcepts.php" title="alexandre gomes:  Basic Concepts of Chipmunk">basic concepts</a>.&nbsp;  I highly recommend taking a look at the tutorial if you&#8217;re considering using Chipmunk.  </p>
<p>Once I got started actually porting iPuck, I only encountered a couple of small snags.&nbsp;  The first came when I was still working with permutations of Mr. Gomes&#8217; sample.&nbsp;  I couldn&#8217;t figure out how to grab an object and drag it around on the screen.&nbsp;  After a bit of searching on the extremely useful <a href="http://www.slembcke.net/forums/viewforum.php?f=1" title="Chipmunk Physics Forums">Chipmunk forum</a>, I found some <a href="http://www.slembcke.net/forums/viewtopic.php?f=6&#038;t=196" title="cpMouse post">sample code</a> that provided most of what I needed.&nbsp;  I&#8217;m led to believe that there will soon be better ways to do this in Chipmunk.&nbsp;  However, after a bit of customization, <a href="http://www.slembcke.net/forums/viewtopic.php?f=6&#038;t=196" title="cpMouse post"><span STYLE="font-family:Courier;">cpMouse</span></a> met the needs for iPuck v1.1.&nbsp;  I plan to look at some of the other methods to see whether I can continue to improve the code.&nbsp;  Look out v1.2.</p>
<p>The other problem was my fault for not reading the <a href="http://code.google.com/p/chipmunk-physics/wiki/cpShape" title="Chipmunk cpShape Documentation"><span STYLE="font-family:Courier;">cpShape</span> documentation</a> more thoroughly.&nbsp;  I had originally modeled a number of my static objects as <span STYLE="font-family:Courier;">cpSegmentShape</span>s.&nbsp;  This worked really well as long as my active objects were all <span STYLE="font-family:Courier;">cpCircleShape</span>s.&nbsp;  Unfortunately, when I tried to model an active object using segments, I discovered that the current version of Chipmunk does not support <span STYLE="font-family:Courier;">cpSegment</span>-to-<span STYLE="font-family:Courier;">cpSegment</span> collisions.&nbsp;  After I went back and converted to <span STYLE="font-family:Courier;">cpPolyShape</span>s, everything was perfect.&nbsp;  If I had carefully read the Chipmunk documentation,  before I started coding, I would have seen:</p>
<blockquote><p><em>Line segments: Meant mainly as a static shape. They can be attached to moving bodies, but they don&#8217;t currently generate collisions with other line segments.</em></p></blockquote>
<p>I needed to develop against a stable library, so I chose to stick with the 4.1.0 version.&nbsp;  Judging by the activity in the project archive, there has been substantial progress since 4.1.0 and I&#8217;m looking forward to working with the latest revisions when they&#8217;ve settled into a steady state.</p>
<p>If you&#8217;re working with rigid bodies, and you need a fast, accurate, easy to use and, best of all, license fee free, 2D physics library, <a href="http://code.google.com/p/chipmunk-physics/" title="chipmunk-physics">Chipmunk</a> may be a perfect match for your needs.</p>
<p>&nbsp;<br />
&#8212;&#8212;&#8211;<br />
Note:&nbsp;  Instructions for using <a href="http://subversion.tigris.org/" title="Subversion project home page">Subversion</a> to check out the code and demos are <a href="http://code.google.com/p/chipmunk-physics/source/checkout" title="Chipmunk SVN co instructions">here</a>.<br />
&#8212;&#8212;&#8211;<br />
Technorati Tags:&nbsp; <a href="http://technorati.com/tag/iPhone" rel="tag">iPhone</a>, <a href="http://technorati.com/tag/iPod+Touch" rel="tag">iPod Touch</a>, <a href="http://technorati.com/tag/Apple" rel="tag">Apple</a>, <a href="http://technorati.com/tag/mobile" rel="tag">mobile</a>, <a href="http://technorati.com/tag/Chipmunk+Physics" rel="tag">chipmunk physics</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/07/chipmunk-2d-physics-on-the-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross SDK Code Hygiene in Xcode</title>
		<link>http://www.BluMtnWerx.com/blog/2009/06/cross-sdk-code-hygiene-in-xcode/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/06/cross-sdk-code-hygiene-in-xcode/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 22:25:31 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=153</guid>
		<description><![CDATA[With the upcoming 3.0 Version of iPhone OS, several methods have been deprecated.&#160;  We'll cover a technique for ensuring that you get clean compiles with both 2.x.y and 3.0.]]></description>
			<content:encoded><![CDATA[<p>I am a big believer in clean compiles.&nbsp;  Unless it&#8217;s absolutely impossible, which is rare, I want my code to compile with no warnings.&nbsp;  This is partly just discipline, but it&#8217;s also because I&#8217;ve run into cases where I missed real problems because I didn&#8217;t notice the issue amongst the compiler warnings that I was ignoring.</p>
<p>With 3.0, several methods that were used in 2.x.y are now deprecated.&nbsp;  Use of these methods will generate warnings in 3.0.&nbsp;  Unfortunately, the correct code for 3.0 won&#8217;t work in 2.2.1, for example:</p>
<p><strong>Perfectly good 2.2.1 code:</strong></p>
<p><span STYLE="font-family:Courier;">&nbsp;  &nbsp;  [startButton setFont:playFont];</span></p>
<p><strong>Clean compiling 3.0 code:</strong></p>
<p><span STYLE="font-family:Courier;">&nbsp;  &nbsp;  [[startButton titleLabel] setFont:playFont];</span></p>
<p>So we&#8217;re faced with a problem.&nbsp;  How do we write code that compiles cleanly in 3.0, while maintaining our ability to do clean 2.2.1 (I&#8217;m tired of the 2.x.y notation &#8211; just assume that I&#8217;m talking generically about version 2 of the SDK) builds?</p>
<p>When we first encountered this, I found several suggestions, most of which were wrong to one degree or another.&nbsp;  As nearly as I can tell, the method that I&#8217;m suggesting is more generally workable.</p>
<p>Restating the problem, we need to write our code so that it compiles cleanly, and works, with both a strictly 2.2.1 version of the SDK and with a 3.0 version.&nbsp;  We get extra bonus points if the code won&#8217;t need to be revised when the successor to 3.0 comes out.</p>
<p>Because of the requirement to continue to work with strict 2.2.1, we can&#8217;t rely on the preprocessor constant for 3.0 being defined.&nbsp;  There&#8217;s also an interesting issue between the simulator and the device that I&#8217;ll cover later.</p>
<p>Anyway, here&#8217;s what we came up with:</p>
<p><span STYLE="font-family:Courier;">#ifndef __IPHONE_3_0<br />
#define __IPHONE_3_0 30000<br />
#endif<br />
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0<br />
&nbsp;  &nbsp;  [[startButton titleLabel] setFont:playFont];<br />
#else<br />
&nbsp;  &nbsp;  [startButton setFont:playFont];<br />
#endif</span></p>
<p>When I&#8217;m building against the 3.0 SDK, <span STYLE="font-family:Courier;">__IPHONE_3_0</span> is defined by Xcode, so my directives don&#8217;t interfere.&nbsp;  If all you wanted was the answer, you can stop here.&nbsp;  If you&#8217;d like more background on this issue, please continue reading.</p>
<p>First, a bit about where the pertinent preprocessor #defines are specified.&nbsp;  The file is <span STYLE="font-family:Courier;">Availability.h</span></p>
<p>For the simulator, the full pathname to Availability.h is:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;">/Developer/Platforms/iphoneSimulator.platform/Developer/SDKs/</span>&nbsp;  <strong>&crarr;</strong><br />
&nbsp;  &nbsp;  &nbsp;  &hellip; &nbsp;  <span STYLE="font-family:Courier;">iPhoneSimulator2.2.1.sdk/usr/include/Availability.h</span></p>
<p>For the device the path is:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;">/Developer/Platforms/iphoneOS.platform/Developer/SDKs/</span>&nbsp;  <strong>&crarr;</strong><br />
&nbsp;  &nbsp;  &nbsp;  &hellip; &nbsp;  <span STYLE="font-family:Courier;">iPhoneOS2.2.1.sdk/usr/include/Availability.h</span></p>
<p>In the version of Availability.h that goes along with 2.2.1, the following are defined:</p>
<p><span STYLE="font-family:Courier;">#define __IPHONE_2_0     20000<br />
#define __IPHONE_2_1     20100<br />
#define __IPHONE_2_2     20200</span></p>
<p>Note that there is no <span STYLE="font-family:Courier;">__IPHONE_2_2_1</span></p>
<p>Now, here&#8217;s the tricky bit.&nbsp;  With Xcode, the mechanisms for communicating the version of the SDK that you&#8217;re using differ between builds for the simulator and builds for the device.&nbsp;  When compiling for the simulator, Xcode&#8217;s default configuration for a 2.2.1 build sets a flag as follows:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;">-D__IPHONE_OS_VERSION_MIN_REQUIRED=20000</span></p>
<p>If you&#8217;re paying attention, you&#8217;ll notice that, when building for the simulator, targeting the 2.2.1 SDK, Xcode is setting the flag to 20000.</p>
<p>When building for the device, on the other hand, Xcode uses a completely different technique.&nbsp;  Instead of defining a version value for the preprocessor, the preprocessor substitutes:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;">__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__</span></p>
<p>in place of:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;">__IPHONE_OS_VERSION_MIN_REQUIRED</span>.</p>
<p>Xcode (according to the comments in AvailabilityInternal.h) then has the compiler set:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;">__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__</span></p>
<p>by using <span STYLE="font-family:Courier;">-miphoneos-version-min</span>.&nbsp;  The actual compile directive when building for the 2.2.1 SDK is:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;">-miphoneos-version-min=2.2.1</span></p>
<p>The implication of this is that, when you build for the simulator, the following code:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;">NSLog(@&quot;MIN VERS REQD:  %d &#45;&#45; Current Version:  %d&quot;,</span>&nbsp;  <strong>&crarr;</strong><br />
&nbsp;  &nbsp;  &nbsp;  &hellip; &nbsp;  <span STYLE="font-family:Courier;">__IPHONE_OS_VERSION_MIN_REQUIRED,__IPHONE_2_2);</span></p>
<p>Causes this string to be output to the console:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;"><strong>MIN VERS REQD:  20000 &#45;&#45; Current Version:  20200</strong></span></p>
<p>The exact same code, running on the actual device, produces:</p>
<p>&nbsp;  &nbsp;  <span STYLE="font-family:Courier;"><strong>MIN VERS REQD:  20201 &#45;&#45; Current Version:  20200</strong></span></p>
<p>The reason I shared this in painful detail is to explain why some of the solutions that people are suggesting for this issue might not work in the general case.</p>
<p>Assuming that we&#8217;re building for the simulator as many of us do during development, the default Xcode configuration won&#8217;t let us find out whether we&#8217;re using any SDK later than 2.0.&nbsp;  For example, if we have code that goes something like:</p>
<p><span STYLE="font-family:Courier;">// DO NOT DO THIS<br />
#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_2_2<br />
&nbsp;  &nbsp;  [[startButton titleLabel] setFont:playFont];<br />
#else<br />
&nbsp;  &nbsp;  [startButton setFont:playFont];<br />
#endif</span></p>
<p>This code will work on the simulator because <span STYLE="font-family:Courier;">__IPHONE_OS_VERSION_MIN_REQUIRED</span> will be 20000, which is not greater than 20200.&nbsp;  It will <strong>not</strong> work on the device, however, because 20201 is greater than 20200.&nbsp;  Remember that there is no official definition of <span STYLE="font-family:Courier;">_IPHONE_2_2_1</span>.&nbsp;  Sigh&#8230;</p>
<p>Another approach that I considered was:</p>
<p><span STYLE="font-family:Courier;">// THIS MIGHT WORK, BUT I DON&#8217;T RECOMMEND IT<br />
#ifndef __IPHONE_3_0<br />
&nbsp;  &nbsp;  NSLog(@&quot;THE 3.0 SDK IS NOT DEFINED&quot;);<br />
#else<br />
&nbsp;  &nbsp;  NSLOG(@&quot;THE 3.0 SDK IS DEFINED&quot;);<br />
#endif</span></p>
<p>The problem here is that I&#8217;m not testing the value, I&#8217;m simply seeing if it&#8217;s defined.&nbsp;  If the variable ever gets defined in my code (perhaps due to a bit like what I&#8217;m proposing) or if the Xcode ever picks up a version of Availability.h that defines <span STYLE="font-family:Courier;">__IPHONE_3_0</span> when you&#8217;re building for 2.2.1 (I know that this shouldn&#8217;t happen, but better safe than sorry) the preproccesor will eliminate the wrong lines of code.&nbsp;  Remember that there are multiple versions of Availability.h kicking around on your system.&nbsp;  Check out the one at <span STYLE="font-family:Courier;">/usr/include/Availability.h</span> sometime.</p>
<p>&nbsp;  </p>
<p>&#8212;&#8212;&#8211;<br />
Technorati Tags:&nbsp; <a href="http://technorati.com/tag/iPhone" rel="tag">iPhone</a>, <a href="http://technorati.com/tag/iPod+Touch" rel="tag">iPod Touch</a>, <a href="http://technorati.com/tag/iPhone+OS" rel="tag">iPhone OS</a>, <a href="http://technorati.com/tag/Xcode" rel="tag">Xcode</a>,<a href="http://technorati.com/tag/Apple" rel="tag">Apple</a>, <a href="http://technorati.com/tag/mobile" rel="tag">mobile</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/06/cross-sdk-code-hygiene-in-xcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing Audio on the iPhone</title>
		<link>http://www.BluMtnWerx.com/blog/2009/06/playing-audio-on-the-iphone/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/06/playing-audio-on-the-iphone/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 05:51:56 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[AudioSession]]></category>
		<category><![CDATA[AVAudioPlayer]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>
		<category><![CDATA[OpenAL]]></category>
		<category><![CDATA[SoundEngine]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=151</guid>
		<description><![CDATA[The iPhone SDK has a rich set of support services for playing audio.&#160;  Sometimes the challenge is selecting the best fit for a particular situation.]]></description>
			<content:encoded><![CDATA[<p>Almost everything covered in this post is available in Apple&#8217;s excellent developer documentation, but many of us don’t seem to have the patience to &#8220;go to the source,&#8221; so I&#8217;ll try to extract some of the choice bits out here.</p>
<p>One of the questions that I&#8217;ve faced myself, and that I&#8217;ve now tried to answer many times for others, is, &#8220;Which method should I use to play sounds for my app?&#8221;</p>
<p>Here&#8217;s the overview, right from Apple&#8217;s <a href="http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/GS_AudioVideo_iPhone/index.html" title="iPhone Reference Library:&nbsp;  Audio and Video">Getting Started with Audio &#038; Video</a> document:</p>
<blockquote><p><em><strong>Playing Audio and Invoking Vibration</strong><br />
Depending on your needs, you play audio in iPhone OS using System Sound Services, the AVAudioPlayer class, Audio Queue Services, OpenAL, or the I/O audio unit.</p>
<ul>
<li>To play alerts and user-interface sound effects, or to invoke vibration, use System Audio Services. This technology can play .caf, .wav, and .aif files containing sounds with durations of 30 seconds or less. Refer to “<a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/AudioandVideoTechnologies.html#//apple_ref/doc/uid/TP40007072-CH19-SW3" title="iPhone OS Programming Guide:  Audio and Visual Technologies">Using Sound in iPhone OS</a>” in <a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/index.html#//apple_ref/doc/uid/TP40007072" title="iPhone OS Programming Guide">iPhone Application Programming Guide</a> and to <a href="http://developer.apple.com/iphone/library/documentation/AudioToolbox/Reference/SystemSoundServicesReference/index.html#//apple_ref/doc/uid/TP40007916" title="Audio ToolBox Reference:  System Sound Services Reference">System Sound Services Reference</a>.</li>
<li>To play sounds of any duration, to play multiple sounds simultaneously [dgs- see comments on this below], or to play sounds with level control, use the AVAudioPlayer class. This technology can play any audio format supported in iPhone OS including MP3, AAC, ALAC (Apple Lossless), IMA4, linear PCM, and others. See <a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/index.html#//apple_ref/doc/uid/TP40007072" title="iPhone OS Programming Guide">iPhone Application Programming Guide</a> and <a href="http://developer.apple.com/iphone/library/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/index.html#//apple_ref/doc/uid/TP40008067" title="AVFoundation:  AVAudioPlayer Class Reference">AVAudioPlayer Class Reference</a>.</li>
<li>To play sounds with precise control—such as for synchronization—or to play audio captured from an Internet stream, use Audio Queue Services. See <a href="http://developer.apple.com/iphone/library/documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/index.html#//apple_ref/doc/uid/TP40005343" title="Music and Audio:  AudioQueue Programming Guide">Audio Queue Services Programming Guide</a> and <a href="http://developer.apple.com/iphone/library/documentation/MusicAudio/Reference/AudioQueueReference/index.html#//apple_ref/doc/uid/TP40005117" title="Music and Audio:  AudioQueue Reference">Audio Queue Services Reference</a>. For sample code, see <a href="http://developer.apple.com/iphone/library/samplecode/SpeakHere/index.html#//apple_ref/doc/uid/DTS40007802" title="Sample Code:  SpeakHere">SpeakHere</a>.</li>
<li>To play positional audio, especially if your application is a game, use OpenAL, an open source technology documented at <a href="http://openal.org">http://openal.org</a>. See <a href="http://developer.apple.com/iphone/library/technotes/tn2008/tn2199.html#//apple_ref/doc/uid/DTS40007999" title="Technical Note TN2199:  OpenAL FAQ for iPhone OS">OpenAL FAQ for iPhone OS</a> for important information on using this technology in iPhone OS. For sample code, see <a href="http://developer.apple.com/iphone/library/samplecode/oalTouch/index.html#//apple_ref/doc/uid/DTS40007769" title="Sample Code:  oalTouch">oalTouch</a>.</li>
<li>To play sounds with lowest I/O latency, or to provide simultaneous audio input and output, use the I/O audio unit. See the <a href="http://developer.apple.com/iphone/library/samplecode/aurioTouch/index.html#//apple_ref/doc/uid/DTS40007770" title="Sample Code:  aurioTouch">aurioTouch sample.</a></li>
</ul>
<p></em></p></blockquote>
<p>Some details that are left out of this overview, including:</p>
<p><strong>Compressed Formats on the iPhone</strong> &mdash; The bottom line here is that the higher level frameworks on the iPhone will only play one highly compressed sound at a time.&nbsp;  This is due to limitations in the processing available to decompress sounds in the audio pipeline.&nbsp;  You might be able to get around this by implementing your own decoder and feeding the resulting uncompressed audio to either OpenAL, or AudioQueue, but that&#8217;s beyond my interests at this point.&nbsp;  Apple&#8217;s statement above regarding AVAudioPlayer could be a bit misleading, because AVAudioPlayer will <strong>not</strong> play multiple MP3 sounds simultaneously.&nbsp;  Here&#8217;s the section from <a href="http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/" title="Coding How-Tos: Audio and Video">Coding How-Tos: Audio and Video</a>:</p>
<blockquote><p><em>The following limitations pertain for simultaneous sounds in iPhone OS, depending on the audio data format:</p>
<ul>
<li>AAC, MP3, and ALAC (Apple Lossless) audio: no simultaneous playback; one sound at a time.</li>
</ul>
<p></em>
</p></blockquote>
<p><strong>Can I Play an MP3 with SystemAlerts?</strong>  &mdash; No.&nbsp;  SystemAudioServices only plays sounds in linear PCM or IMA4 (IMA/ADPCM) format, packaged as a .caf, .aif, or .wav file.&nbsp;  AVAudioPlayer, on the other hand, supports the playback of any audio format available in the iPhone OS.&nbsp;  This is documented in the <a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/AudioandVideoTechnologies.html#//apple_ref/doc/uid/TP40007072-CH19-SW24" title="iPhone Application Programming Guide: Multimedia Support">iPhone Application Programming Guide: Multimedia Support</a></p>
<p><strong>Why not just stick with AVAudioPlayer?</strong> &mdash; AVAudioPlayer is fine, if you don&#8217;t need <a href="http://en.wikipedia.org/wiki/3D_audio_effect" title="Wikipedia:  3D Audio Effect">positional audio</a> and if you&#8217;re not worried about some <a href="http://www.blumtnwerx.com/blog/2009/05/adventures-in-sound-land/" title="Adventures in Sound Land">significant delays</a> in starting up each player.&nbsp;  This latter bit can be especially important if you&#8217;re trying to fire off sounds in a tight loop, or if you need to synchronize effects in a multi-threaded environment.</p>
<p><strong>What I you recommend?</strong> &mdash; Use <strong><em>SystemAudioServices</em></strong> if your sounds are short and available in the proper formats.&nbsp;  It&#8217;s by far the simplest player and, within its constraints, it pretty much handles everything for you.&nbsp;  Use <strong><em>AVAudioPlaye</em>r</strong> for operations like playing songs or recorded speech.&nbsp;  Unfortunately, Apple doesn&#8217;t sanction SoundEngine anymore, but I&#8217;ve become a big fan of using <strong><em>SoundEngine</em></strong> on top of <strong><em>OpenAL</em></strong> for games.&nbsp;  This combination hides some of the complexities of OpenAL while still giving you access to most of the standard stuff.&nbsp;  Also, it&#8217;s easy to <a href="http://www.blumtnwerx.com/blog/2009/05/adventures-in-sound-land/" title="Adventures in Sound Land">extend</a> SoundEngine to get at pretty much any OpenAL functionality you need.&nbsp;  We downloaded the source for SoundEngine from the <a href="http://oolongengine.com/" title="Oolong Game Engine">Oolong site</a>, but it might be a bit easier to grab it directly from <a href="http://code.google.com/p/cocos2d-iphone/source/browse/tags/release-0.2.1/AudioSupport/" title="cocos2d-iphone:  AudioSupport">coocos2d.</a></p>
<p>A final word.&nbsp;  With pretty much everything beyond SystemAudioServices, you&#8217;ll want to seriously consider managing the <strong><em>Audio Session</em></strong> yourself.&nbsp;  As always, Apple provides excellent <a href="http://developer.apple.com/iphone/library/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Introduction/Introduction.html" title="iPhone Reference Library:  Audio Session Programming Guide">documentation</a>.&nbsp;  Even Apple encourages you to take care of this detail:</p>
<blockquote><p><em>Each iPhone OS application gets an audio session object, usually called an audio session. This object comes with some default behavior that you can use to get started in development. Except for certain special cases, however, the default behavior is unsuitable for a shipping application.</em></p></blockquote>
<p>You don&#8217;t need to instantiate an AudioSession object.&nbsp;  The iPhone OS provides every app with a singleton AudioSession when the app launches.&nbsp;  However, you do have to initialize the AudioSession.&nbsp;  You may also need to set properties, and you&#8217;ll probably want to Activate/Deactivate the session.</p>
<p>Happy sounds!</p>
<p>&nbsp;  </p>
<p>&#8212;&#8212;&#8211;<br />
Technorati Tags:&nbsp; <a href="http://technorati.com/tag/iPhone" rel="tag">iPhone</a>, <a href="http://technorati.com/tag/iPod+Touch" rel="tag">iPod Touch</a>, <a href="http://technorati.com/tag/Apple" rel="tag">Apple</a>, <a href="http://technorati.com/tag/mobile" rel="tag">mobile</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/06/playing-audio-on-the-iphone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Couple More Xcode Keys</title>
		<link>http://www.BluMtnWerx.com/blog/2009/05/a-couple-more-xcode-keys/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/05/a-couple-more-xcode-keys/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 03:46:01 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=147</guid>
		<description><![CDATA[These are documented, but some new developers haven't encountered them yet, so maybe I can save you some time.]]></description>
			<content:encoded><![CDATA[<p>There are a handful of Xcode keyboard shortcuts that I find particularly useful.&nbsp;  Although the keys are documented, some folks have apparently not come across them, yet.&nbsp;  Hopefully, using these keys will help your productivity as much as it does mine.</p>
<p>First, let&#8217;s consider <strong>Code Completion</strong>.&nbsp;  Two keys here are particularly useful.&nbsp;  <span STYLE="font-family: Courier;" ><strong>&lt;ctl&gt;+.</strong> <em>(control + period)</em></span> cycles through the list of possible completions for the token that you&#8217;ve typed, while pressing <span STYLE="font-family: Courier;" ><strong>&lt;esc&gt;</strong></span> brings up the full list of possible completions.&nbsp;  The Xcode menu suggests <span STYLE="font-family: Courier;" ><strong>&lt;opt&gt;+&lt;esc&gt;</strong> <em>(alt/option + escape)</em></span> for this action, but just <span STYLE="font-family: Courier;" >&lt;esc&gt;</span> seems to work fine.</p>
<p>If code completion doesn&#8217;t seem to be working for you, be sure to check the setting for the Automatically Suggest menu in Xcode&#8217;s Code Sense preferences.</p>
<p>Another shortcut that I use frequently is <span STYLE="font-family: Courier;" ><strong>&lt;ctl&gt;+/</strong> <em>(control + slash)</em></span>, which cycles between the placeholders highlighted by Code Completion.&nbsp;  Sometimes you can also accomplish this with the arrow keys, but <span STYLE="font-family: Courier;" >&lt;ctl&gt;+forward slash</span> always works.</p>
<p>Happy Xcoding!</p>
<p>&nbsp;<br />
&#8212;&#8212;&#8211;<br />
Technorati Tags:&nbsp; <a href="http://technorati.com/tag/iPhone" rel="tag">iPhone</a>, <a href="http://technorati.com/tag/iPod+Touch" rel="tag">iPod Touch</a>, <a href="http://technorati.com/tag/Apple" rel="tag">Apple</a>, <a href="http://technorati.com/tag/mobile" rel="tag">mobile</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/05/a-couple-more-xcode-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>But I Want to Play That Same Sound Again, Right Now</title>
		<link>http://www.BluMtnWerx.com/blog/2009/05/but-i-want-to-play-that-same-sound-again-right-now/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/05/but-i-want-to-play-that-same-sound-again-right-now/#comments</comments>
		<pubDate>Sat, 23 May 2009 05:01:23 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[AudioSession]]></category>
		<category><![CDATA[AVAudioPlayer]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>
		<category><![CDATA[OpenAL]]></category>
		<category><![CDATA[SoundEngine]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=132</guid>
		<description><![CDATA[One of the most interesting challenges that I ran into in our sound heavy application (still waiting App Store approval) was figuring out how to play a second, third, etc. instance of a sound while the original was still playing.]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in an <a href="http://www.blumtnwerx.com/blog/2009/05/adventures-in-sound-land/" title="Post:&nbsp;  Adventures in SoundLand">earlier post</a>, I&#8217;ve been dipping my toes into the deep waters of iPhone sound.&nbsp;  One of the challenges that I ran into recently involved figuring out the best way to play a sound again, while the previous instance of the same sound was still playing.&nbsp;  Although our current application features several (OK, sixteen) distinct sounds, the app often attempts to play a sound that is already playing.&nbsp;  With <code>AudioServicesPlaySystemSound</code> this just works.&nbsp;  The subsequent attempts to play a sound simply play right along.&nbsp;  Unfortunately, neither SoundEngine, nor AVAudioPlayer, work this way.&nbsp;  If you try to start a SoundEngine effect, or an AVAudioPlayer, again, while it is already playing, nothing happens.&nbsp;  It doesn&#8217;t queue; it just doesn&#8217;t play.</p>
<p>Before I go any further, I should share some of the details of the sounds for this app.&nbsp;  They are all relatively short (roughly 2 seconds, or less).&nbsp;  Their intensity peaks early, tapers quickly to a relatively low level, then trails off very gently for most of their duration.&nbsp;  Their time domain plot looks something like a question mark rotated -90 degrees, then mirrored across the x-axis.</p>
<p>Since, as <a href="http://www.blumtnwerx.com/blog/2009/05/adventures-in-sound-land/" title="Why I Could Not Use AudioServices">previously discussed</a>, I couldn&#8217;t use AudioServices, I had to figure out a way to make either SoundEngine/OpenAL, or AVAudioPlayer (which was later rejected for a different reason), work.&nbsp;  Some of my less embarrassing attempts to solve this included:</p>
<p>The first tactic that I tried was to simply stop the currently playing effect/player (for the sake of simplicity, I&#8217;ll just refer to both as <em>players</em> for the rest of this post) and start it again.&nbsp;  Unfortunately, this introduced a distinct, and very unpleasant, click when the stop/start happened.&nbsp;  If your app is a shooter, with lots of sharp explosions and weapon reports, this might not be a problem, but it was a showstopper for us.</p>
<p>The next thing that I tried was gradually reducing the volume of the current player before stopping it.&nbsp;  That didn&#8217;t help, much.</p>
<p>With AVAudioPlayer, I also tried just setting the player back to the beginning, instead of stopping it. <code>[myPlayer setCurrentTime:0.0]</code> &#8211; the results were actually worse than a stop/restart.</p>
<p>At that point, I decided to try a combination approach.&nbsp;  If the subsequent attempt to play came early in the original player&#8217;s span, I just skipped the later attempt.&nbsp;  If the attempt came well into the original, I gradually reduced the volume of the original, stopped it and then started the player again.&nbsp;  This was better, because there were fewer stop/starts, but it still wasn&#8217;t perfect.&nbsp;  Which leads us to the solution that I ended up implementing&#8230;</p>
<p>In the end, I went with a backup player technique.&nbsp;  I have two players set up to play each sound (I used players here to be consistent.&nbsp;  They&#8217;re really effects, since I&#8217;m using SoundEngine/OpenAL).&nbsp;  If the first one is busy, I use the second one.&nbsp;  If both are busy, I skip playing the sound.&nbsp;  I was all set to go even deeper, to three, or even four, players for each sound.&nbsp;  Fortunately, two gave good results, and the code was straightforward, so I stuck with a single level of backup.</p>
<p>I probably should have tried this first, but I was worried about both the memory and the execution overhead of having multiple players for each sound.&nbsp;  My concern was not warranted.&nbsp;  With the current implementation, the overhead is negligible, and the results are great.</p>
<p>&nbsp;  </p>
<p>&#8212;&#8212;&#8211;</p>
<p>Technorati Tags:&nbsp; <a href="http://technorati.com/tag/iPhone" rel="tag">iPhone</a>, <a href="http://technorati.com/tag/iPod+Touch" rel="tag">iPod Touch</a>, <a href="http://technorati.com/tag/Apple" rel="tag">Apple</a>, <a href="http://technorati.com/tag/mobile" rel="tag">mobile</a>, <a href="http://technorati.com/tag/SoundEngine" rel="tag">SoundEngine</a>, <a href="http://technorati.com/tag/AVAudio" rel="tag">AVAudio</a>, <a href="http://technorati.com/tag/AudioServices" rel="tag">AudioServices</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/05/but-i-want-to-play-that-same-sound-again-right-now/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adventures in Sound Land</title>
		<link>http://www.BluMtnWerx.com/blog/2009/05/adventures-in-sound-land/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/05/adventures-in-sound-land/#comments</comments>
		<pubDate>Tue, 12 May 2009 01:18:33 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[AudioSession]]></category>
		<category><![CDATA[AVAudioPlayer]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>
		<category><![CDATA[OpenAL]]></category>
		<category><![CDATA[SoundEngine]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=117</guid>
		<description><![CDATA[Who would have imagined that getting the sound to work even close to the way that we wanted would be much harder than writing the app?&#160;  Maybe I can help you avoid some of the pitfalls.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a new App for much longer than we&#8217;d budgeted.&nbsp;  The sad part is that the real coding has been complete for several days.&nbsp;  Instead of submitting this app and getting on with the next one, I&#8217;ve spent the time trying to iron out sound issues.&nbsp;  This isn&#8217;t a complicated app, but it does, on occasion, play multiple short (&lt;2 sec) sounds simultaneously.&nbsp;  The sounds are not complex, and I was initially hoping to skate by with the AudioServices system sounds.&nbsp;  I know that that&#8217;s not the recommended practice, but it was the easiest to code, so I started there.</p>
<p>The problem with that approach quickly became apparent.&nbsp;  There was a noticeable distortion when more than 2-3 sounds were playing at the same time.&nbsp;  The unpleasant effect was kind of a stuttering static, sort of like one might hear if one over-drives speakers.&nbsp;  This, unfortunately, pretty much ruined the effect of the app, so <a href="http://www.blumtnwerx.com/BMWTeam.html#Paul">Paul</a> suggested lowering the volume of the sounds.&nbsp;  Sadly, one can&#8217;t do that for an AudioServices system sound.</p>
<p>At that point, I switched the app over to using AVAudioPlayer.&nbsp;  This seemed like it was going to be a good solution, so I wrote a utility app to help me test the individual sound volume settings and spent quite a bit of time experimenting to find the &#8220;right&#8221; level for each possible combination of sounds.&nbsp;  I really thought that I was in the home stretch until I fired up the app and found that the motion went from butter smooth to unacceptably jerky.&nbsp;  Since actual playback of AVAudioPlayer is asynchronous with regards to the main thread, the last thing that I looked at (after wasting more time than I should have on optimization) was the actual call to [myAVAudioPlayer play].&nbsp;  Big mistake.</p>
<p>After eliminating everything else, I bracketed the [myAVAudioPlayer play] calls with a timer and was amazed to discover that the calls were taking 0.04 &#8211; 0.05 seconds, on the calling thread, just to get started.&nbsp;  After that, the player went along asynchronously, as expected.&nbsp;  Since my simulation loop was running in increments of 0.0167 seconds, having each call to [myAVAudioPlayer play] block for 3x that amount made for a very unhappy user experience.&nbsp;  My next thought was to bounce right to OpenAL, but I decided that the (apparently) no longer sanctioned <em>(at least it&#8217;s not available from Apple anymore)</em> SoundEngine might give me most of what I needed, without my having to worry about managing buffers and sources.  </p>
<p>Unfortunately, SoundEngine lacked some OpenAL functionality that I really needed (being able to find out if a given effect is currently playing and also to find out how far along the effect is).&nbsp;  I ended up implementing extensions to SoundEngine to get at the OpenAL stuff, and, so far, everything is working.&nbsp;  The most recent discovery was that the SoundEngine/OpenAL combination does not initialize and properly configure an AudioSession.&nbsp;   This means that our app stopped when the device went into Auto-Lock.&nbsp;  Not necessarily a good thing for a &#8220;lifestyle&#8221; app.&nbsp;  Once I took care of that, I&#8217;m back to calibrating the sound levels and doing more testing on the functionality.&nbsp;  I constantly have my fingers crossed that I don&#8217;t encounter any more problems that will force me to abandon the extended SoundEngine.</p>
<p>I may do a longer post on the perils of using compressed audio formats in the future, but let&#8217;s wrap this bit up with a warning.&nbsp;  While compression can really help with your download times, you may want to be careful about choosing when to employ compressed formats.&nbsp;  There are a couple of reasons for this.&nbsp;  First, some of the iPhone SDK playback options support only a limited subset of the compressed formats.&nbsp;  Second, the device won&#8217;t play the highly compressed formats simultaneously.&nbsp;  If you plan to play multiple sounds at the same time, highly compressed formats might not be an option.</p>
<p>Most of the points covered here are well documented in the <a href="http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/GS_AudioVideo_iPhone/index.html" title="iPhone Developer Connection Document">Getting Started with Audio &amp; Video</a> document.&nbsp;  If I&#8217;d had the discipline to read the whole thing before I started down this path, the trip would have been much less frustrating.</p>
<p>Technorati Tags:&nbsp; <a href="http://technorati.com/tag/iPhone" rel="tag">iPhone</a>, <a href="http://technorati.com/tag/iPod+Touch" rel="tag">iPod Touch</a>, <a href="http://technorati.com/tag/Apple" rel="tag">Apple</a>, <a href="http://technorati.com/tag/mobile" rel="tag">mobile</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/05/adventures-in-sound-land/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Shortcut for &#8220;Go to Counterpart&#8221;</title>
		<link>http://www.BluMtnWerx.com/blog/2009/04/shortcut-for-go-to-counterpart/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/04/shortcut-for-go-to-counterpart/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 21:26:56 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=71</guid>
		<description><![CDATA[I've been doing lots of coding lately, and using "Go to Counterpart" quite a bit.&#160;  This keyboard shortcut makes my work much easier.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s crunch time for getting the first BluMtnWerx apps ready for release, so I&#8217;ve been neglecting my writing responsibilities.   This will be a short one, as I&#8217;ve got lots of code to write (OK, debug) before I sleep.   Anyway, when I&#8217;m in the &#8220;code &#8217;til I drop&#8221; mode, I find myself using Xcode&#8217;s &#8220;Go to Couterpart&#8221; quite a bit.   This is, at least partly, because I get too tired to actually remember what&#8217;s in the header file.   Anyway, I finally got fed up with moving the cursor up to the icon every time I wanted to toggle between header and source files, so I went looking for a shortcut.   What did we do before Google?   When I first started using Xcode, I tried to find an answer in the program&#8217;s documentation, but I got frustrated and gave up.   Of course, a fraction of a second with Google gave me the answer:</p>
<p>    &lt;<strong>Command</strong>&gt;+&lt;<strong>Option</strong>&gt;+↑   <em>(that&#8217;s</em> &lt;<strong>UpArrow</strong>&gt;<em>)</em></p>
<p>…toggles between header and source.   As the result is a toggle, a similarly modified ↓ isn&#8217;t required to invert the operation.   If I&#8217;d looked through Xcode&#8217;s menus, I could also have dug it up &#8211; it&#8217;s under the View menu &#8211; but I&#8217;m not a menu guy, I&#8217;d never even looked at the View menu until I started this post.</p>
<p>That&#8217;s it for today&#8217;s tip, enjoy&#8230;</p>
<p>Postscript:   I tried to use angle brackets:   〈 and 〉 in this post.  Every browser that I checked, except IE, handled them just fine.   Sigh…</p>
<p>Technorati Tags:  <a rel="tag" href="http://technorati.com/tag/iPhone">iPhone</a>, <a rel="tag" href="http://technorati.com/tag/iPod+Touch">iPod Touch</a>, <a rel="tag" href="http://technorati.com/tag/Apple">Apple</a>, <a rel="tag" href="http://technorati.com/tag/mobile">mobile</a>, <a rel="tag" href="http://technorati.com/tag/Xcode">Xcode</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/04/shortcut-for-go-to-counterpart/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Musings on the Sometimes Maligned Interface Builder</title>
		<link>http://www.BluMtnWerx.com/blog/2009/03/musings-on-the-sometimes-maligned-interface-builder/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/03/musings-on-the-sometimes-maligned-interface-builder/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 20:18:45 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[IB]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=55</guid>
		<description><![CDATA[I've seen both positive and negative comments regarding IB.&#160;  Put me squarely in the fan camp.&#160;  While the application has some odd issues, the benefits of being able to do your interface design on screen, using drag &#038; drop, more than compensate for the challenges.&#160;  In fact, there are pretty straightforward ways to overcome many of the limitations.&#160;  We'll talk about one "trick" in this post.]]></description>
			<content:encoded><![CDATA[<p>We all know Interface Builder (IB) as the visual design tool that some of use to lay out UIs for iPhones / iPod Touches.   When I was trying to figure out how to use it, I encountered a great deal of commentary both positive, and negative.   While there will always be those who prefer to do everything programmatically, I&#8217;m one of the lazy ones who appreciates tools that let me accomplish my tasks without writing heaps of potentially buggy code.</p>
<p>IB lets me position my controls interactively, and it provides somewhat straightforward hooks for connecting my program to the new controls.   One of the big complaints that I noticed, and one that frustrated me a bit, at least at first, was that IB doesn&#8217;t provide full access to all of the settings on the controls that it specifies.   The specific example for me was setting the font for the <span style="font-family: Courier;">Title</span> text for the regular &quot;<span style="font-family: Courier;">Round Rect Button</span>.&quot;   Support for this operation is clearly evident via the &quot;<span style="font-family: Courier;">setfont:</span>&quot; method specified in the class header file, but I couldn&#8217;t find any way to get at the method through the IB Attributes Inspector.</p>
<p>As suggested above, I&#8217;m pretty lazy, so I didn&#8217;t want to abandon IB just to change the font face and size, then a solution appeared.   I simply established an outlet to the specific button:</p>
<p><span style="font-family: Courier;">@interface ButtonTestViewController : UIViewController {</span><br />
&#8230;<br />
<span style="font-family: Courier;">IBOutlet UIButton *theButton;</span><br />
&#8230;</p>
<p>and wrote the following code:<br />
&#8230;<br />
<span style="font-family: Courier;">UIFont *theFont = [UIFont boldSystemFontOfSize:30];<br />
[theButton setFont:theFont];<br />
CGSize tOff = CGSizeMake(2.0,2.0);<br />
[theButton setTitleShadowOffset:tOff];</span><br />
&#8230;</p>
<p>For what it&#8217;s worth, my situation was such that I was able to put the code to set the button in the <span style="font-family: Courier;">viewDidLoad</span> method.</p>
<p>One other thing to keep in mind when you&#8217;re loading your application from a nib, the ViewController&#8217;s initWithCoder is the initialization method that gets called.   Thanks to <a href="http://www.blumtnwerx.com/blog/2009/03/book-recommendation-beginning-iphone-development/">Jeff LaMarche</a> for the explanation of initializers in his response to <a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/2364-question-about-initwithnibname.html">this question</a>.</p>
<p>Unless you just love writing and maintaining UI code, I strongly urge you to take a careful look at IB.   I&#8217;ll continue to use it whenever I can.</p>
<p>Technorati Tags:  <a rel="tag" href="http://technorati.com/tag/iPhone">iPhone</a> , <a rel="tag" href="http://technorati.com/tag/iPod+Touch">iPod Touch</a> , <a rel="tag" href="http://technorati.com/tag/Apple">Apple</a> , <a rel="tag" href="http://technorati.com/tag/mobile">mobile</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/03/musings-on-the-sometimes-maligned-interface-builder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Joy of Screen Real Estate</title>
		<link>http://www.BluMtnWerx.com/blog/2009/03/the-joy-of-screen-real-estate/</link>
		<comments>http://www.BluMtnWerx.com/blog/2009/03/the-joy-of-screen-real-estate/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 06:45:35 +0000</pubDate>
		<dc:creator>deans</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[iPhone Dev Tools]]></category>
		<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://www.BluMtnWerx.com/blog/?p=36</guid>
		<description><![CDATA[While I love my MacBook, a 13-inch monitor just doesn't give me enough space for development.&#160;  I ended up having to get a second screen.]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t say enough good things about my MacBook, but, if I had it all to do over again, I might have gone for an <a href="http://www.apple.com/imac/">iMac</a>.&nbsp;  As I&#8217;m mostly chained to my desk trying to write applications, portability isn&#8217;t a big issue.&nbsp;  Having enough screen space for header files, the iPhone simulator and the various source files that I&#8217;m working on turns out to be the real requirement.&nbsp;  I just picked up a refurbished 20 inch Dell UltraSharp monitor and a <a href="http://store.apple.com/us/product/MB570Z/A">mini-DisplayPort to DVI adapter</a> for the MacBook.&nbsp;  Now I&#8217;m, a happy coder.&nbsp;  The MacBooks are sure seductive, but I need more display space to be productive.</p>
<p>BTW, if you order an iMac, be sure to consider whether the <a href="http://store.apple.com/us/product/MB110LL/A">full size keyboard (with Numeric Keypad)</a> is a better fit for you than the now standard <a href="http://store.apple.com/us/product/MB869LL/A">Apple Keyboard</a>.&nbsp;  The full size keyboard doesn&#8217;t add to the cost of the system, but you do have to select it explicitly as you order.&nbsp;  I didn&#8217;t realize how much I used both &#8220;Delete&#8221; and &#8220;Backspace,” until I used the MacBook keyboard and had to use Fn-Del for forward Delete.</p>
<p>Technorati Tags:&nbsp; <a href="http://technorati.com/tag/iPhone" rel="tag">iPhone</a>, <a href="http://technorati.com/tag/iPod+Touch" rel="tag">iPod Touch</a>, <a href="http://technorati.com/tag/Apple" rel="tag">Apple</a>, <a href="http://technorati.com/tag/mobile" rel="tag">mobile</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.BluMtnWerx.com/blog/2009/03/the-joy-of-screen-real-estate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
