<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:go='http://ns.gigaom.com/'
xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>GigaOM &#187; Apple</title>
	<atom:link href="http://gigaom.com/apple/tag/bickboxx/feed/" rel="self" type="application/rss+xml" />
	<link>http://gigaom.com</link>
	<description></description>
	<lastBuildDate>Sun, 27 May 2012 08:45:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gigaom.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/0db8f6557d022075dbbf010c54d46d93?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>GigaOM &#187; Apple</title>
		<link>http://gigaom.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gigaom.com/osd.xml" title="GigaOM" />
	<atom:link rel='hub' href='http://gigaom.com/?pushpress=hub'/>
		<item>
		<title>iPhone Dev Sessions:  Adding Analytics to Your App</title>
		<link>http://gigaom.com/apple/iphone-dev-sessions-adding-analytics-to-your-app/</link>
		<comments>http://gigaom.com/apple/iphone-dev-sessions-adding-analytics-to-your-app/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 14:50:41 +0000</pubDate>
		<dc:creator>Henry Balanon</dc:creator>
				<category><![CDATA[Walkthroughs]]></category>
		<category><![CDATA[bickboxx]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iphone dev sessions]]></category>
		<category><![CDATA[pinch media]]></category>

		<guid isPermaLink="false">http://theappleblog.com/?p=30352</guid>
		<description><![CDATA[Welcome to another episode of TheAppleBlog’s iPhone Dev Sessions. We left off with a drum app tutorial called Bickboxx. For this tutorial, we’re building off of the first Bickboxx project, so go back and finish it if you haven’t already. Or if you want to cheat, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gigaom.com&#038;blog=14960843&#038;post=173214&#038;subd=gigaom2&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img  title="2009-08-09_1936" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1936.png?w=200&h=200" alt="2009-08-09_1936" width="200" height="200" class=" alignleft" /></p>
<p class="excerpt">Welcome to another episode of <a href="http://theappleblog.com/tag/iphone-dev-sessions/">TheAppleBlog’s iPhone Dev Sessions</a>. We left off with a <a href="http://gigaom.com/apple/iphone-dev-sessions-create-a-drum-app/">drum app tutorial called Bickboxx</a>. For this tutorial, we’re building off of the first Bickboxx project, so go back and finish it if you haven’t already. Or if you want to cheat, grab the <a href="http://github.com/balanon/bickboxx/tree/master">Bickboxx code from Github</a>.</p>
<h3>The Story</h3>
<p>The Boss is happy we’ve released <a title="iPhone Dev Sessions: Create a Drum App" href="http://gigaom.com/apple/iphone-dev-sessions-create-a-drum-app/">Bickboxx, the iPhone drum app</a>, but now he wants to know how it’s doing. Not just sales-wise.</p>
<p>How many people use our app? How many times have they used the app? How much time do they spend using our app? How many users do we have in each city, state and country? How many illegal haxored versions are out there? How many people open the app once and never use it again?</p>
<p>Yikes. That’s a lot of questions.</p>
<p>Lucky for us, we don’t have to write hundreds of lines of code and roll our own analytics server to track the answer to these questions.</p>
<p>There are dozens of iPhone analytics APIs that will do all of the heavy lifting for us. <a href="http://www.flurry.com/">Flurry</a>, <a href="http://www.mobclix.com/">Mobclix</a>, and <a href="http://www.medialets.com/">Medialets</a> come to mind.</p>
<p>There isn’t a clear leader in iPhone analytics yet but for this tutorial we’ll be using <a href="http://www.pinchmedia.com/">Pinch Analytics</a>. It has comprehensive documentation and its reporting is detailed as well. <span id="more-173214"></span></p>
<h3>Signing Up for a Pinch Media Account</h3>
<p>The first thing you want to do is <a title="Pinch Media - Register" href="http://developer.pinchmedia.com/users/register">sign up for a Pinch Media account</a>. The first part of registration is the usual username/email/password page. The second part detailing your app takes you to this:</p>
<p><img  title="2009-08-09_1248" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1248.png?w=570&h=512" alt="2009-08-09_1248" width="570" height="512" class=" alignleft" /></p>
<p>Since Bickboxx isn’t a real app that you’ll be distributing, you don’t have to fill out any of this. You can skip this part by clicking the “I’ll do it later” button.</p>
<p>When you are adding analytics to your real-life app, I’ve filled out some sample data for you to go by. Note that if you don’t add an app into Pinch Media, you won’t be able to view any analytics reports.</p>
<h3>Download and Install the Pinch Media SDK</h3>
<p>After you’ve signed up for an account, <a href="http://developer.pinchmedia.com/analytics/library/download">download and unzip the SDK</a>.</p>
<p>Open up the Bickboxx project in Xcode. Drag the <strong>Beacon+FBConnect.h</strong> and <strong>Beacon.h</strong> files into the Classes directory in the Xcode project.</p>
<p><img  title="2009-08-09_1433" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1433.png?w=570&h=360" alt="2009-08-09_1433" width="570" height="360" class=" alignleft" /></p>
<p>Make sure the “Copy items into destination group’s folder (if needed)” checkbox is checked. Click Add. We do this so our code knows how to access the Pinch Media methods in the <strong>libPMAnalytics-rXX.a</strong> library.</p>
<p><img  title="2009-08-09_1430" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1430.png?w=570&h=360" alt="2009-08-09_1430" width="570" height="360" class=" alignleft" /></p>
<p>We’ll need to import the <strong>libPMAnalytics-rXX.a</strong> library next. Do this by dragging the <strong>libPMAnalytics-rXX.a</strong> file to the Frameworks folder in Xcode. Again, make sure the “Copy items into destination group’s folder (if needed)” checkbox is checked. Click Add.</p>
<p><img  title="2009-08-09_1433a" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1433a.png?w=570&h=360" alt="2009-08-09_1433a" width="570" height="360" class=" alignleft" /></p>
<h3>Install the Supporting SDKs</h3>
<p>We need a few more frameworks to get going. We may not use these frameworks directly, but Pinch Analytics does.</p>
<p>Ctrl-Click the Frameworks folder and choose <strong>Add → Existing Frameworks&#8230;</strong></p>
<p><img  title="2009-08-09_1441" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1441.png?w=528&h=267" alt="2009-08-09_1441" width="528" height="267" class=" alignleft" /></p>
<p>Select <strong>libsqlite3.dylib</strong> and click Add.</p>
<p><img  title="2009-08-09_1442" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1442.png?w=338&h=534" alt="2009-08-09_1442" width="338" height="534" class=" alignleft" /></p>
<p>Do the same for the <strong>SystemConfiguration.framework</strong>.</p>
<p><img  title="2009-08-09_1501" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1501.png?w=338&h=534" alt="2009-08-09_1501" width="338" height="534" class=" alignleft" /></p>
<p>Lastly, do the same for <strong>CoreLocation.framework</strong>.</p>
<p><img  title="2009-08-09_1502" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1502.png?w=338&h=534" alt="2009-08-09_1502" width="338" height="534" class=" alignleft" /></p>
<p>Build the project to make sure everything is in place. It should compile. Got it? Good.</p>
<h3>Adding the Pinch Analytics Code</h3>
<p>Add this import statement for the <strong>Beacon.h</strong> file into <strong>BickBoxxAppDelegate.h</strong>.</p>
<p><pre class="brush: csharp;">
#import “Beacon.h”
</pre></p>
<p>Adding this will allow us access to the Pinch Analytics methods from inside our <strong>BickBoxxAppDelegate.m</strong> file. Your <strong>BickboxxAppDelegate.h</strong> file should now look like this. Our change is in line 2.</p>
<p><pre class="brush: csharp;">
#import &lt;UIKit/UIKit.h&gt;
#import &quot;Beacon.h&quot;

@class BickBoxxViewController;

@interface BickBoxxAppDelegate : NSObject &lt;UIApplicationDelegate&gt; {
  UIWindow *window;
  BickBoxxViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet BickBoxxViewController *viewController;

@end
</pre></p>
<p>Open up <strong>BickBoxxAppDelegate.m</strong> and locate the <code>applicationDidFinishLaunching</code> method. Add this line of code.</p>
<p><pre class="brush: csharp;">
NSString *applicationCode = @"REPLACE THIS WITH YOUR APPLICATION CODE";
</pre></p>
<p>Replace the <code>REPLACE THIS WITH YOUR APPLICATION CODE</code> with your Application Code from Pinch Media. You can find your application code in <a href="http://developer.pinchmedia.com/applications/">your Pinch Media account</a>.</p>
<p><img  title="2009-08-09_1559" src="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1559.png?w=570&h=327" alt="2009-08-09_1559" width="570" height="327" class=" alignleft" /></p>
<p>This is your unique ID that Pinch Media uses to identify which app is sending data to them. If you opted to not setup an app during registration, you need to do this to get an Application Code. If you don’t put in a valid Application Code, you won’t get any analytics reports and you’re wasting your time.</p>
<p>We’re going to use this <code>applicationCode</code> NSString to activate our analytics beacon. Add this line of code to the <code>applicationDidFinishLaunching</code> method.</p>
<p><pre class="brush: csharp;">
[Beacon initAndStartBeaconWithApplicationCode:applicationCode
    useCoreLocation:YES useOnlyWiFi:NO];
</pre></p>
<p>This fires up the analytics code when the app launches. Note that we’re sending in the <code>applicationCode</code> NSString that we inserted in the previous step. Also note the <code>useCoreLocation</code> parameter. You can set this to <code>YES</code> or <code>NO</code> depending on whether you want to capture location statistics.</p>
<p>Use this with caution. If you think you’ll offend your users by asking for their location, set this to <code>NO</code>.</p>
<p>Another parameter is <code>useOnlyWiFi</code>. Not everyone in the world has an unlimited data plan. They&#8217;ll be none to happy if your app is sending data over the mobile network when they don’t want it to.</p>
<p>Like the <code>useCoreLocation</code> parameter, use this parameter with caution. If set to <code>YES</code>, the analytics data will be sent to Pinch Media only when they’re connected to Wi-Fi. This way, the people who pay their mobile carrier per kilobyte won’t get mad. The downside is that you will miss usage statistics if they never connect to Wi-Fi.</p>
<p>If you’re not worried about being responsible for someone’s data overages, set this to <code>NO</code>.</p>
<p>Your code in <strong>BickBoxxAppDelegate.m</strong> for the <code>applicationDidFinishLaunching</code> method should now look like this.</p>
<p><pre class="brush: csharp;">
- (void)applicationDidFinishLaunching:(UIApplication *)application {

	// New code below this
	NSString *applicationCode = @"REPLACE THIS WITH YOUR APPLICATION CODE";
  [Beacon initAndStartBeaconWithApplicationCode:applicationCode
								 useCoreLocation:YES useOnlyWiFi:NO];

  // Old code below this
	[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

  // Override point for customization after app launch
  [window addSubview:viewController.view];
  [window makeKeyAndVisible];
}
</pre></p>
<p>Finally, when we exit the app or your app crashes (your apps never crash right?), we need to stop the analytics beacon.</p>
<p>Add this method to the <strong>BickBoxxAppDelegate.m</strong> file.</p>
<p><pre class="brush: csharp;">
- (void)applicationWillTerminate:(UIApplication *)application {
  [[Beacon shared] endBeacon];
}
</pre></p>
<p>Build and run your app.</p>
<h3>You’re Done!</h3>
<p>That’s it &#8212; you’re done! Go to lunch and have a sandwich. Nothing’s changed to the user except it’s going to ask if it’s okay that Bickboxx uses their location. You can now login to Pinch Media’s site and see all your pretty statistics and graphs. Worth noting is that the data isn’t real-time &#8212; it’s only updated twice a day.</p>
<h3>Homework</h3>
<p>The Boss is happy now that we can measure the performance of our app. He wants more detail on which buttons are pressed the most. You can do this by adding sub-beacons, which you can read about at <a href="http://resources.pinchmedia.com/docs/Pinch_Analytics/">the documentation site</a>.</p>
<h3>BickBoxx On Github and the iTunes App Store</h3>
<p><a href="http://gigaom.com/apple/iphone-dev-sessions-create-a-drum-app/">Like last time</a>, the code is <a href="http://github.com/balanon/bickboxx/tree/master">open-sourced on Github</a>. You can check your code against the code here if you start to stumble.</p>
<p>We’re here to show you how to build actual apps. You can download the app as it’s built at the <a href="http://a.bickbot.com/boxx">iTunes App Store</a>. More info on the open-source/open-tutorialized efforts on <a href="http://bickbot.com/bickboxx">the BickBoxx website</a>.</p>
<p><strong>Related research and analysis from GigaOM Pro:</strong><br />Subscriber content. <a href="http://pro.gigaom.com/?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=173214+iphone-dev-sessions-adding-analytics-to-your-app&utm_content=balanon">Sign up for a free trial</a>.</p><ul><li><a href="http://pro.gigaom.com/2011/01/mobile-q4-all-eyes-were-on-android-4g-and-the-rising-tablet-tide/?utm_source=apple&amp;utm_medium=editorial&amp;utm_campaign=waterfall?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=173214+iphone-dev-sessions-adding-analytics-to-your-app&utm_content=balanon">Mobile Q4: All Eyes Were on Android, 4G and the Rising Tablet&nbsp;Tide</a></li><li><a href="http://pro.gigaom.com/2010/12/report-a-mobile-video-market-overview/?utm_source=apple&amp;utm_medium=editorial&amp;utm_campaign=waterfall?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=173214+iphone-dev-sessions-adding-analytics-to-your-app&utm_content=balanon">Report: A Mobile Video Market&nbsp;Overview</a></li><li><a href="http://pro.gigaom.com/2010/10/in-q3-the-tablet-and-4g-were-the-big-stories/?utm_source=apple&amp;utm_medium=editorial&amp;utm_campaign=waterfall?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=173214+iphone-dev-sessions-adding-analytics-to-your-app&utm_content=balanon">In Q3, the Tablet and 4G Were the Big&nbsp;Stories</a></li></ul><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gigaom.com&#038;blog=14960843&#038;post=173214&#038;subd=gigaom2&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gigaom.com/apple/iphone-dev-sessions-adding-analytics-to-your-app/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e0c66e7aa8ea6f9b5fdd72fb70545d4c?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">balanon</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1936.png" medium="image">
			<media:title type="html">2009-08-09_1936</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1248.png?w=570" medium="image">
			<media:title type="html">2009-08-09_1248</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1433.png?w=570" medium="image">
			<media:title type="html">2009-08-09_1433</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1430.png?w=570" medium="image">
			<media:title type="html">2009-08-09_1430</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1433a.png?w=570" medium="image">
			<media:title type="html">2009-08-09_1433a</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1441.png" medium="image">
			<media:title type="html">2009-08-09_1441</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1442.png" medium="image">
			<media:title type="html">2009-08-09_1442</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1501.png" medium="image">
			<media:title type="html">2009-08-09_1501</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1502.png" medium="image">
			<media:title type="html">2009-08-09_1502</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/08/2009-08-09_1559.png?w=570" medium="image">
			<media:title type="html">2009-08-09_1559</media:title>
		</media:content>
	</item>
		<item>
		<title>iPhone Dev Sessions: Create a Drum App</title>
		<link>http://gigaom.com/apple/iphone-dev-sessions-create-a-drum-app/</link>
		<comments>http://gigaom.com/apple/iphone-dev-sessions-create-a-drum-app/#comments</comments>
		<pubDate>Mon, 11 May 2009 18:00:10 +0000</pubDate>
		<dc:creator>Henry Balanon</dc:creator>
				<category><![CDATA[CNN Mobile]]></category>
		<category><![CDATA[SYN Feature Enterprise]]></category>
		<category><![CDATA[Walkthroughs]]></category>
		<category><![CDATA[bickboxx]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iphone dev sessions]]></category>

		<guid isPermaLink="false">http://theappleblog.com/?p=22658</guid>
		<description><![CDATA[You’ve seen all the different drum apps, right? Well, they’re really easy to make. In this iPhone Dev Sessions article, I want to teach you how to make Bickboxx, an actual app that’s in the iTunes App Store. Grab Bickboxx (FREE) from the iTunes App Store [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gigaom.com&#038;blog=14960843&#038;post=172691&#038;subd=gigaom2&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img  title="BickBoxx-1" src="http://gigapple.files.wordpress.com/2009/05/bickboxx-1.jpg?w=250&h=248" alt="BickBoxx-1" width="250" height="248" class=" alignleft" /></p>
<p class="excerpt">You’ve seen all the different drum apps, right? Well, they’re really easy to make. In this <a href="http://theappleblog.com/tag/iphone-dev-sessions/">iPhone Dev Sessions</a> article, I want to teach you how to make Bickboxx, an actual app that’s in the <a href="http://a.bickbot.com/boxx">iTunes App Store</a>.</p>
<p>Grab <a href="http://a.bickbot.com/boxx">Bickboxx</a> (FREE) from the iTunes App Store if you want to see this puppy in action so you have an idea of what you&#8217;re building. Also, I’ve opened up the <a href="http://github.com/balanon/bickboxx/">source code</a> for free at Github. Feel free to download it, report issues, or even fork your own version and change it as you see fit.</p>
<p>More info on the open-source community project at <a href="http://bickbot.com/bickboxx/">Bickbot&#8217;s Bickboxx page</a>.</p>
<p>Note: You don’t need to download the code from Github to get through the tutorial.</p>
<h3>An On-going Project</h3>
<p>I plan on adding more tutorials with enhancements to this project. Here are a couple of things that could be featured in future iPhone Dev Sessions.</p>
<ul>
<li>Key logger</li>
<li>Adding analytics tracking</li>
<li>Adding application preferences</li>
<li>Track recorder and editor</li>
<li>Vibration feedback</li>
<li>Add your own custom sounds</li>
<li>Access your iPod library as a background track</li>
</ul>
<p>Leave a comment with other enhancements you want to learn.</p>
<p>OK, let&#8217;s get to creating Bickboxx! <span id="more-172691"></span></p>
<h3>Get Started</h3>
<p>Create a new View-based project in XCode. Name the project &#8220;Bickboxx&#8221;.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/createnewproject.png?w=604" alt="" class=" alignleft" /></p>
<p><a href="http://a.theappleblog.com/downloads/BickboxxAssets.zip">Download this zip file</a> and unzip it. These are all the sounds, images, and icons you need for Bickboxx. Drag all these files to the Resources. Hat tip to <a href="http://twitter.com/ellenich">John Ellenich</a> for the graphics/sounds.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/dragtoresources.png?w=604" alt="" class=" alignleft" /></p>
<p>You need to copy the item to the project’s directory, so put a check mark next to “Copy items into destination group’s folder (if needed).” Your settings should look similar to this. Click Add.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/copyitems.png?w=604" alt="" class=" alignleft" /></p>
<h3>Adding the background image in Interface Builder</h3>
<p>Double-click <em><strong>BickboxxViewController.xib</strong></em> to open it in Interface Builder. Drag an Image View (<code>UIImageView</code>) from the Library to the View window. This will act as a placement holder for our background image.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/image-5101.png?w=510&amp;h=415" alt="" class=" alignleft" /></p>
<p>Bring up the Attributes Inspector. Set the Image to <code>Background.png</code>.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/background_png.png?w=604" alt="" class=" alignleft" /></p>
<h3>Creating the Button in Interface Builder</h3>
<p>Drag a Round Rect Button (<code>UIButton</code>) to the View.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/dragbutton.png?w=604" alt="" class=" alignleft" /></p>
<p>Bring up the Attributes Inspector. We don’t want the button to look like an ugly white rectangle. Set the Type to Custom.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/custombutton.png?w=604" alt="" class=" alignleft" /></p>
<p>Further down the Attributes Inspector, set the button’s state to Normal (or Default State Configuration depending on your version of Xcode). This is what the button looks like when it’s not doing anything.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/normalbutton.png?w=604" alt="" class=" alignleft" /></p>
<p>Set the button’s Image to <code>B Inactive.png</code>.  You need to resize the button in the View to make sure the “B” button is fully shown.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/binactive.png?w=604" alt="" class=" alignleft" /></p>
<p>Now, change the button’s state to Highlighted (or Highlighted State Configuration depending on your version of Xcode). This is what the button looks like when it’s pressed down.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/bactive.png?w=604" alt="" class=" alignleft" /></p>
<p>Set the button’s Image to <code>B Active.png</code>.</p>
<p>Drag another Round Rect Button (<code>UIButton</code>) to the View and repeat this section for the letters “E”, “A”, and “T”. Your View should now look like this:</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/beatfull.png?w=604" alt="" class=" alignleft" /></p>
<p>Close Interface Builder for now.</p>
<p>Build and Go to make sure everything is still working. Touch the buttons, and they should light up.</p>
<h3>Adding the Sounds Code</h3>
<p>We have an interface that doesn’t do anything. Let’s fix that. The audio framework we need isn’t added by default. We have to add the AudioToolbox framework.</p>
<p>Control+Click the Frameworks folder on the left. Go to <strong>Add → Existing Frameworks&#8230;</strong></p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/addframework.png?w=604" alt="" class=" alignleft" /></p>
<p>Select the <em><strong>AudioToolbox.framework</strong></em> from <em><strong>/System/Library/Frameworks</strong></em>.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/audiotoolbox.png?w=604" alt="" class=" alignleft" /></p>
<p>Click OK and add it to the project.</p>
<p>Open <em><strong>BickboxxViewController.h</strong></em> and add this code to it.</p>
<p><pre class="brush: csharp;">

#import &lt;UIKit/UIKit.h&gt;
#import &lt;AudioToolbox/AudioServices.h&gt;

@interface BickboxxViewController : UIViewController {
    CFURLRef        bNoteFileURLRef;
    SystemSoundID    bNoteFileObject;
    CFURLRef        eNoteFileURLRef;
    SystemSoundID    eNoteFileObject;
    CFURLRef        aNoteFileURLRef;
    SystemSoundID    aNoteFileObject;
    CFURLRef        tNoteFileURLRef;
    SystemSoundID    tNoteFileObject;
}

@property (readwrite)    CFURLRef        bNoteFileURLRef;
@property (readonly)    SystemSoundID    bNoteFileObject;
@property (readwrite)    CFURLRef        eNoteFileURLRef;
@property (readonly)    SystemSoundID    eNoteFileObject;
@property (readwrite)    CFURLRef        aNoteFileURLRef;
@property (readonly)    SystemSoundID    aNoteFileObject;
@property (readwrite)    CFURLRef        tNoteFileURLRef;
@property (readonly)    SystemSoundID    tNoteFileObject;

@end

</pre></p>
<p>At the top, we’re referencing <strong>AudioServices.h</strong> from the AudioToolbox framework we imported earlier.</p>
<p>Below that is the declaration of properties for four sounds for the “B”, “E”, “A” and “T” buttons.</p>
<p><code>bNoteFileURLRef</code> is the file location reference for the <code>bNoteFileObject</code>. This is the sound the “B” button will make.</p>
<p>These are the properties for the “E”, “A” and “T” sounds as well.</p>
<h3>The BickboxxViewController.m File</h3>
<p>Open <em><strong>BickboxxViewController.m</strong></em>. We need to synthesize the getters/setters for our properties.</p>
<p>You can do this by adding this after <code>@implementation BickBoxxViewController</code>:</p>
<p><pre class="brush: csharp;">

@synthesize bNoteFileURLRef, bNoteFileObject, eNoteFileURLRef,
eNoteFileObject, aNoteFileURLRef, aNoteFileObject,
tNoteFileURLRef, tNoteFileObject;

</pre></p>
<h3>Changing the viewDidLoad Method</h3>
<p>Locate the <code>viewDidLoad</code> method. It will be commented out. You want to uncomment it to activate it.</p>
<p>The <code>viewDidLoad</code> method gets called after all the UI components are created. This is a good place for any startup code you need your app to perform. In this case, we’ll need to set our properties to the correct sounds.</p>
<p>The first thing we need to do in <code>viewDidLoad</code> is get the main bundle for the app. The main bundle allows you to use a folder hierarchy to organize and locate many types of application resources including images, sounds, localized strings, and executable code.</p>
<p>After <code>[super viewDidLoad];</code>, add this code to get the main bundle for the app.</p>
<p><pre class="brush: csharp;">

// Get the main bundle for the app
CFBundleRef mainBundle;
mainBundle = CFBundleGetMainBundle ();

</pre></p>
<p>To build the sound for the “B” button, we need to get the path of the sound file we want to play. The name of the sound file is <em><strong>B.aifc</strong></em>. This is the code to get the URL to the found file to play. Put this code after the code where you get the main bundle.</p>
<p><pre class="brush: csharp;">

// Get the URL to the sound file to play
bNoteFileURLRef  =    CFBundleCopyResourceURL (
                                             mainBundle,
                                             CFSTR ("B"),
                                             CFSTR ("aifc"),
                                             NULL
                                             );

</pre></p>
<p>Note that valid system sound packages are <code>.wav</code>, <code>.aif</code> and <code>.caf</code> files.</p>
<p>Now that we have <code>bNoteFileURLRef</code> set we can associate the sound file with the system sound object <code>bNoteFileObject</code>. The <code>AudioServicesPlaySystemSound</code> function lets you very simply play short sound files.</p>
<p>Add this code after the code that gets the sound file URL.</p>
<p><pre class="brush: csharp;">

// Create a system sound object representing the sound file
AudioServicesCreateSystemSoundID (bNoteFileURLRef, &bNoteFileObject);

</pre></p>
<p>We finished loading up the sound for the &#8220;B&#8221; button. We’ll need to load up the sounds for the “E”, “A” and “T” buttons.</p>
<p>Try to code this part yourself. If you get stuck, the <code>viewDidLoad</code> method should look like this when you&#8217;re done.</p>
<p><pre class="brush: csharp;">

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    // Get the main bundle for the app
    CFBundleRef mainBundle;
    mainBundle = CFBundleGetMainBundle ();

    // Get the URL to the sound file to play
    bNoteFileURLRef  =    CFBundleCopyResourceURL (
                                                 mainBundle,
                                                 CFSTR ("B"),
                                                 CFSTR ("aifc"),
                                                 NULL
                                                 );

    // Create a system sound object representing the sound file
    AudioServicesCreateSystemSoundID (bNoteFileURLRef, &bNoteFileObject);

    // Get the URL to the sound file to play
    eNoteFileURLRef  =    CFBundleCopyResourceURL (
                                                 mainBundle,
                                                 CFSTR ("E"),
                                                 CFSTR ("aifc"),
                                                 NULL
                                                 );

    // Create a system sound object representing the sound file
    AudioServicesCreateSystemSoundID (eNoteFileURLRef, &eNoteFileObject);

    // Get the URL to the sound file to play
    aNoteFileURLRef  =    CFBundleCopyResourceURL (
                                                 mainBundle,
                                                 CFSTR ("A"),
                                                 CFSTR ("aifc"),
                                                 NULL
                                                 );
    // Create a system sound object representing the sound file
    AudioServicesCreateSystemSoundID (aNoteFileURLRef, &aNoteFileObject);

    // Get the URL to the sound file to play
    tNoteFileURLRef  =    CFBundleCopyResourceURL (
                                                 mainBundle,
                                                 CFSTR ("T"),
                                                 CFSTR ("aifc"),
                                                 NULL
                                                 );

    // Create a system sound object representing the sound file
    AudioServicesCreateSystemSoundID (tNoteFileURLRef, &tNoteFileObject);
}

</pre></p>
<h3>Creating Our IBActions</h3>
<p>Our BEAT buttons need to be associated with IBActions to make them do something. First, let’s declare the methods. Open <em><strong>BickboxxViewController.h</strong></em> and add this code before the <code>@end</code> line.</p>
<p><pre class="brush: csharp;">
- (IBAction)bSound:(id)sender;
- (IBAction)eSound:(id)sender;
- (IBAction)aSound:(id)sender;
- (IBAction)tSound:(id)sender;
</pre></p>
<p>Your <em><strong>BickboxxViewController.h</strong></em> should now look like:</p>
<p><pre class="brush: csharp;">

#import &lt;UIKit/UIKit.h&gt;
#import &lt;AudioToolbox/AudioServices.h&gt;

@interface BickBoxxViewController : UIViewController {
    CFURLRef        bNoteFileURLRef;
    SystemSoundID    bNoteFileObject;
    CFURLRef        eNoteFileURLRef;
    SystemSoundID    eNoteFileObject;
    CFURLRef        aNoteFileURLRef;
    SystemSoundID    aNoteFileObject;
    CFURLRef        tNoteFileURLRef;
    SystemSoundID    tNoteFileObject;
}

@property (readwrite)    CFURLRef        bNoteFileURLRef;
@property (readonly)    SystemSoundID    bNoteFileObject;
@property (readwrite)    CFURLRef        eNoteFileURLRef;
@property (readonly)    SystemSoundID    eNoteFileObject;
@property (readwrite)    CFURLRef        aNoteFileURLRef;
@property (readonly)    SystemSoundID    aNoteFileObject;
@property (readwrite)    CFURLRef        tNoteFileURLRef;
@property (readonly)    SystemSoundID    tNoteFileObject;

// The new code you added
- (IBAction)bSound:(id)sender;
- (IBAction)eSound:(id)sender;
- (IBAction)aSound:(id)sender;
- (IBAction)tSound:(id)sender;

@end

</pre></p>
<p>Close the file and open <em><strong>BickboxxViewController.m</strong></em>. Add the implementation to make the IBAction methods make the appropriate system sounds by invoking the <code>AudioServicesPlaySystemSound</code> method.</p>
<p>To play the “B” sound, the implemented method should make a call to <code>AudioServicesPlaySystemSound</code> and use the <code>bNoteFileObject</code> we created above. Add this after the property synthesis code:</p>
<p><pre class="brush: csharp;">
- (IBAction)bSound:(id)sender {
AudioServicesPlaySystemSound (self.bNoteFileObject);
}
</pre></p>
<p>Add similar implementations for the “E”, “A” and “T” sounds as well.</p>
<p>For reference, the top of <em><strong>BickboxxViewController.m</strong></em> should look like:</p>
<p><pre class="brush: csharp;">

#import "BickBoxxViewController.h" 

@implementation BickBoxxViewController

@synthesize bNoteFileURLRef, bNoteFileObject, eNoteFileURLRef,
eNoteFileObject, aNoteFileURLRef, aNoteFileObject,
tNoteFileURLRef, tNoteFileObject;

- (IBAction)bSound:(id)sender {
    AudioServicesPlaySystemSound (self.bNoteFileObject);
}

- (IBAction)eSound:(id)sender {
    AudioServicesPlaySystemSound (self.eNoteFileObject);
}

- (IBAction)aSound:(id)sender {
    AudioServicesPlaySystemSound (self.aNoteFileObject);
}

- (IBAction)tSound:(id)sender {
    AudioServicesPlaySystemSound (self.tNoteFileObject);
}

</pre></p>
<p>For the last piece of code, we need to clean up our mess so we don’t have memory leaks. At the bottom of <em><strong>BickboxxViewController.m</strong></em>, add these lines to your <code>dealloc</code> method:</p>
<p><pre class="brush: csharp;">

- (void)dealloc {
    [super dealloc];
    AudioServicesDisposeSystemSoundID (self.bNoteFileObject);
    AudioServicesDisposeSystemSoundID (self.eNoteFileObject);
    AudioServicesDisposeSystemSoundID (self.aNoteFileObject);
    AudioServicesDisposeSystemSoundID (self.tNoteFileObject);
    CFRelease (bNoteFileURLRef);
    CFRelease (eNoteFileURLRef);
    CFRelease (aNoteFileURLRef);
    CFRelease (tNoteFileURLRef);
}

</pre></p>
<p>We&#8217;re done coding. Build and Go the project to make sure nothing is on fire. Your buttons won&#8217;t make any sounds yet. We&#8217;ll need to link our code to our interface.</p>
<h3>Linking the buttons to the code in Interface Builder</h3>
<p>Now that our code is done, we can link our buttons to our code. We’ll start with the “B” button link it with the <code>bsound</code> method. To do this, open up <em><strong>BickboxxViewController.xib</strong></em>.</p>
<p>Control+Click on the File’s Owner object so we can link our “B” button to our <code>bsound</code>.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/rightclickfilesowner.png?w=604" alt="" class=" alignleft" /></p>
<p>Drag from the <code>bSound</code> in File’s Owner to the “B” button in the View.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/fromfilesownertobutton.png?w=604" alt="" class=" alignleft" /></p>
<p>An overlay should pop up. Choose Touch Down. The normal default is to execute the action when the finger is lifted from the button. We don’t want that. Soundboards don’t work that way. This will call the <code>bSound</code> IBAction method when the button is pressed down.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/touchdown.png?w=604" alt="" class=" alignleft" /></p>
<p>Do this linking with the rest of the buttons. When you’re done, Control+Clicking File’s owner should look like this.</p>
<p><img src="http://gigapple.files.wordpress.com/2009/04/allbuttonslinked.png?w=604" alt="" class=" alignleft" /></p>
<p>Here&#8217;s a video of me using Bickboxx to practice for my opening act for Paul Oakenfold.</p>
<span style="text-align:center; display: block;"><a href="http://gigaom.com/apple/iphone-dev-sessions-create-a-drum-app/"><img src="http://img.youtube.com/vi/OBUA_cpSm1A/2.jpg" alt="" /></a></span>
<h3>You’re done!</h3>
<p>That’s it &#8212; you’re done! Compile and run this and you’ll be DJ-ing parties with Moby in no time.</p>
<p>Again, you can download the source from social coding site <a href="http://github.com/balanon/bickboxx/">Github</a>. Feel free to file issues here if the code needs fixing or enhancing.</p>
<h3>Homework</h3>
<p>Are you ready to apply your newfound knowledge? Solidify it with this extra credit assignment.</p>
<p>Your homework: Add a new button and a new sound to the project.</p>
<p>If there are any typos, problems, suggestions, or questions, let me know here in the comments.</p>
<p><strong>Related research and analysis from GigaOM Pro:</strong><br />Subscriber content. <a href="http://pro.gigaom.com/?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=172691+iphone-dev-sessions-create-a-drum-app&utm_content=balanon">Sign up for a free trial</a>.</p><ul><li><a href="http://pro.gigaom.com/2011/01/mobile-q4-all-eyes-were-on-android-4g-and-the-rising-tablet-tide/?utm_source=apple&amp;utm_medium=editorial&amp;utm_campaign=waterfall?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=172691+iphone-dev-sessions-create-a-drum-app&utm_content=balanon">Mobile Q4: All Eyes Were on Android, 4G and the Rising Tablet&nbsp;Tide</a></li><li><a href="http://pro.gigaom.com/2010/12/report-a-mobile-video-market-overview/?utm_source=apple&amp;utm_medium=editorial&amp;utm_campaign=waterfall?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=172691+iphone-dev-sessions-create-a-drum-app&utm_content=balanon">Report: A Mobile Video Market&nbsp;Overview</a></li><li><a href="http://pro.gigaom.com/2010/10/in-q3-the-tablet-and-4g-were-the-big-stories/?utm_source=apple&amp;utm_medium=editorial&amp;utm_campaign=waterfall?utm_source=apple&utm_medium=editorial&utm_campaign=auto3&utm_term=172691+iphone-dev-sessions-create-a-drum-app&utm_content=balanon">In Q3, the Tablet and 4G Were the Big&nbsp;Stories</a></li></ul><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gigaom.com&#038;blog=14960843&#038;post=172691&#038;subd=gigaom2&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gigaom.com/apple/iphone-dev-sessions-create-a-drum-app/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e0c66e7aa8ea6f9b5fdd72fb70545d4c?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">balanon</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/05/bickboxx-1.jpg" medium="image">
			<media:title type="html">BickBoxx-1</media:title>
		</media:content>

		<media:content url="http://gigapple.files.wordpress.com/2009/04/createnewproject.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/dragtoresources.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/copyitems.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/image-5101.png?w=510&#38;h=415" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/background_png.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/dragbutton.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/custombutton.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/normalbutton.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/binactive.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/bactive.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/beatfull.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/addframework.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/audiotoolbox.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/rightclickfilesowner.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/fromfilesownertobutton.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/touchdown.png" medium="image" />

		<media:content url="http://gigapple.files.wordpress.com/2009/04/allbuttonslinked.png" medium="image" />
	</item>
	</channel>
</rss>
