<?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>How to Make iPhone Apps &#187; How To</title>
	<atom:link href="http://howtomakeiphoneapps.com/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://howtomakeiphoneapps.com</link>
	<description>Get Started with Cocoa-Touch and iPhone Programming today!</description>
	<lastBuildDate>Fri, 30 Jul 2010 12:27:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How Can I Add Tabs Programmatically To UITabBar?</title>
		<link>http://howtomakeiphoneapps.com/2010/07/how-can-i-add-tabs-programmatically-to-uitabbar/</link>
		<comments>http://howtomakeiphoneapps.com/2010/07/how-can-i-add-tabs-programmatically-to-uitabbar/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 19:04:33 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Programming]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1973</guid>
		<description><![CDATA[Usually when you want UITabBar in your app you can simply add a UITabBarController to your MainWindow.xib. In fact, XCode already comes with a pretty good template that sets up an app with UITabBar for you right out of the box. This is great, but sometimes you want to be able to have your app [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2010/07/how-can-i-add-tabs-programmatically-to-uitabbar/" title="Permanent link to How Can I Add Tabs Programmatically To UITabBar?"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/lg_tab.jpg" width="250" height="400" alt="Post image for How Can I Add Tabs Programmatically To UITabBar?" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p>Usually when you want UITabBar in your app you can simply add a UITabBarController to your MainWindow.xib.  In fact, XCode already comes with a pretty good template that sets up an app with UITabBar for you right out of the box.  This is great, but sometimes you want to be able to have your app dynamically add tabs and the view controllers that go with them.  The only way to do that is to dig into some code.</p>
<h3>UITabBarController Based App</h3>
<p><a style="display:none" href="http://anyurl.com" rel="tag">CodeProject</a></p>
<p>To demonstrate how to add tabs to your app in code I am going to use the Tab Bar Application template in XCode to create a simple tab bar based app.  My app will only start with one screen (and corresponding tab) with a button on it.  When you touch the button the app will magically add a four new tabs and screens to the app.  It will look something like this:</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/OneTabToManyTabs.png"</img></p>
<h3>Set Up Your XCode Project</h3>
<p>The first thing that you need to do is to create a new iOS app.  Open up XCode and choose &#8220;File&#8221; > &#8220;New Project&#8230;&#8221; and select &#8220;Tab Bar Application&#8221;</p>
<p>You will get a template UITabBar application that comes pre-loaded with two tabs.  Both of these tabs have UIViews associated with them but we do not want to use them for our project.  Click on the MainWindow.xib file under the resources folder to open up the main app window in Interface Builder.</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/xcodescreen1.png"</img></p>
<p>In Interface Builder you will see the MainWindow xib file that should look something like this:</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/xcodescreen2.png"</img></p>
<p>Use the button circled in the picture to change how the xib is displayed.  This makes it easier to deal with the UITabBarController.  Your xib file should now look like this:</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/xcodescreen3.png"</img></p>
<p>Highlight the two view controllers that XCode included here for us and delete them both.  Now we are ready to rock.</p>
<h3>Add New UIViewController To Your XCode Project</h3>
<p>Ok, so now let&#8217;s add a new UIViewController called AddManyViewController to the XCode Project.  This UIViewController should have a UIButton on it with its IBOutlet and IBAction already hooked up.  Here is what I did:</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/xcodescreen4.png"</img></p>
<h3>AddManyViewController Header (Interface) File</h3>
<pre>
#import &lt;UIKit/UIKit.h&gt;

@interface AddManyViewController : UIViewController {
	UIButton *button;
}

@property(nonatomic, retain) IBOutlet UIButton *button;

-(IBAction)addMoreTabsToApp;

@end
</pre>
<h3>AddManyViewController Implementation File</h3>
<pre>
#import "AddManyViewController.h"

@implementation AddManyViewController
@synthesize button;

-(IBAction)addMoreTabsToApp{

}

@end
</pre>
<h3>Add AddManyViewController To Tab</h3>
<p>Since we are going to want this screen to open up when the app starts lets make sure to put AddManyViewController into our tab bar.  We can just use Interface Builder for this part.  Go back to your MainWindow.xib file in Interface Builder, select your UITabBarController and then select the first tab on the attributes inspector.</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/xcodescreen5.png"</img></p>
<p>Click the plus sign in under the view controllers section to the AddManyViewController view controller to the tab bar.  You will still need to configure this view controller more by specifying the nib (xib) file and the class that is acting as a controller.  Select the node that appears under the tab bar to do this:</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/xcodescreen6.png"</img></p>
<p>Change the nib name to AddManyViewController.  Now select the last tab on the attributes inspector to specify the controller class.</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/xcodescreen7.png"</img></p>
<p>Ok, save your Interface Builder file and build and run your XCode project.  You should see this pop up in the simulator:</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/xcodescreen8.png"</img></p>
<p>You should be able to click the button but nothing will happen yet.</p>
<h3>Add Code To Dynamically Add Tabs</h3>
<p>Now we are ready to go over to the meat of this article.  When we press the button we want to dynamically add a bunch of tabs to the iPhone.  These will be added in code and they will come into the space with a smooth animation.</p>
<p>Head back over to the IBAction that we started coding earlier on.  This will be located in the AddManyViewController.m file.  We will be starting out with this code:</p>
<pre>
#import "AddManyViewController.h"

@implementation AddManyViewController
@synthesize button;

-(IBAction)addMoreTabsToApp{

}

@end
</pre>
<h4>Create An NSMutableArray</h4>
<p>This array will hold the view controllers that will go into the UITabBar.  While we are here we may as well declare an object variable for our view controllers (I just called it vc below).</p>
<pre>
#import "AddManyViewController.h"

@implementation AddManyViewController
@synthesize button;

-(IBAction)addMoreTabsToApp{
	NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init];
	UIViewController *vc;
}

@end
</pre>
<h4>Create UIViewControllers And Add Them To The Array</h4>
<p>Now what we need to do is to create a few UIViewControllers and add them to the array.  I am just using generic view controllers here but you could just as easily use your own subclassed UIViewController for this.</p>
<pre>
#import "AddManyViewController.h"

@implementation AddManyViewController
@synthesize button;

-(IBAction)addMoreTabsToApp{
	NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init];
	UIViewController *vc;

	vc = [[UIViewController alloc] init];
	vc.title = @"A";
	[listOfViewControllers addObject:vc];
	[vc release];
	vc = [[UIViewController alloc] init];
	vc.title = @"B";
	[listOfViewControllers addObject:vc];
	[vc release];
	vc = [[UIViewController alloc] init];
	vc.title = @"C";
	[listOfViewControllers addObject:vc];
	[vc release];
}

@end
</pre>
<h4>Adding The Tabs</h4>
<p>Here is the fun part &#8211; since we have this array all we need to do is to send a message with the array as a parameter to the UITabBar to add these view controllers to the app.  They will be animated as well which adds a nice touch.</p>
<p>What we are going to do is send the setViewControllers:animated message along with our array to the tab bar.  Luckily, it is easy for us to get access to the tab bar from any view controller since a reference to the tab bar is included as a UIViewController property.</p>
<pre>
#import "AddManyViewController.h"

@implementation AddManyViewController
@synthesize button;

-(IBAction)addMoreTabsToApp{
	NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init];
	UIViewController *vc;

	vc = [[UIViewController alloc] init];
	vc.title = @"A";
	[listOfViewControllers addObject:vc];
	[vc release];
	vc = [[UIViewController alloc] init];
	vc.title = @"B";
	[listOfViewControllers addObject:vc];
	[vc release];
	vc = [[UIViewController alloc] init];
	vc.title = @"C";
	[listOfViewControllers addObject:vc];
	[vc release];

	[self.tabBarController setViewControllers:listOfViewControllers
	                                 animated:YES];
}

@end
</pre>
<h4>Test The App</h4>
<p>At this point you should be able to build and run your app and test your work.  What you should expect to see is something like this:</p>
<p align="center"><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/iphonesim1.png"</img></p>
<p>Take note of the tabs at the bottom of the screen.  Our one AddMore tab has been completely replaced with the A, B and C tabs (and view controllers).  Pretty Nifty!</p>
<h3>What Situations Could You See Using Dynamically Generated Tabs In Your iPhone or iPad App?</h3>
<p>Let us know in the comments below!!!</p>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;title=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&amp;bodytext=Usually%20when%20you%20want%20UITabBar%20in%20your%20app%20you%20can%20simply%20add%20a%20UITabBarController%20to%20your%20MainWindow.xib.%20%20In%20fact%2C%20XCode%20already%20comes%20with%20a%20pretty%20good%20template%20that%20sets%20up%20an%20app%20with%20UITabBar%20for%20you%20right%20out%20of%20the%20box.%20%20This%20is%20great%2C%20but%20s" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;title=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&amp;notes=Usually%20when%20you%20want%20UITabBar%20in%20your%20app%20you%20can%20simply%20add%20a%20UITabBarController%20to%20your%20MainWindow.xib.%20%20In%20fact%2C%20XCode%20already%20comes%20with%20a%20pretty%20good%20template%20that%20sets%20up%20an%20app%20with%20UITabBar%20for%20you%20right%20out%20of%20the%20box.%20%20This%20is%20great%2C%20but%20s" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;t=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;title=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;title=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&amp;annotation=Usually%20when%20you%20want%20UITabBar%20in%20your%20app%20you%20can%20simply%20add%20a%20UITabBarController%20to%20your%20MainWindow.xib.%20%20In%20fact%2C%20XCode%20already%20comes%20with%20a%20pretty%20good%20template%20that%20sets%20up%20an%20app%20with%20UITabBar%20for%20you%20right%20out%20of%20the%20box.%20%20This%20is%20great%2C%20but%20s" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;title=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=Usually%20when%20you%20want%20UITabBar%20in%20your%20app%20you%20can%20simply%20add%20a%20UITabBarController%20to%20your%20MainWindow.xib.%20%20In%20fact%2C%20XCode%20already%20comes%20with%20a%20pretty%20good%20template%20that%20sets%20up%20an%20app%20with%20UITabBar%20for%20you%20right%20out%20of%20the%20box.%20%20This%20is%20great%2C%20but%20s" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;t=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;title=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&amp;body=Usually%20when%20you%20want%20UITabBar%20in%20your%20app%20you%20can%20simply%20add%20a%20UITabBarController%20to%20your%20MainWindow.xib.%20%20In%20fact%2C%20XCode%20already%20comes%20with%20a%20pretty%20good%20template%20that%20sets%20up%20an%20app%20with%20UITabBar%20for%20you%20right%20out%20of%20the%20box.%20%20This%20is%20great%2C%20but%20s" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;title=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F%20How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;t=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&amp;s=Usually%20when%20you%20want%20UITabBar%20in%20your%20app%20you%20can%20simply%20add%20a%20UITabBarController%20to%20your%20MainWindow.xib.%20%20In%20fact%2C%20XCode%20already%20comes%20with%20a%20pretty%20good%20template%20that%20sets%20up%20an%20app%20with%20UITabBar%20for%20you%20right%20out%20of%20the%20box.%20%20This%20is%20great%2C%20but%20s" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F07%2Fhow-can-i-add-tabs-programmatically-to-uitabbar%2F&amp;t=How%20Can%20I%20Add%20Tabs%20Programmatically%20To%20UITabBar%3F&opener=bm&amp;ei=UTF-8&amp;d=Usually%20when%20you%20want%20UITabBar%20in%20your%20app%20you%20can%20simply%20add%20a%20UITabBarController%20to%20your%20MainWindow.xib.%20%20In%20fact%2C%20XCode%20already%20comes%20with%20a%20pretty%20good%20template%20that%20sets%20up%20an%20app%20with%20UITabBar%20for%20you%20right%20out%20of%20the%20box.%20%20This%20is%20great%2C%20but%20s" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2010/07/how-can-i-add-tabs-programmatically-to-uitabbar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Market Your iPhone &amp; iPad Apps</title>
		<link>http://howtomakeiphoneapps.com/2010/06/how-to-market-your-iphone-ipad-apps/</link>
		<comments>http://howtomakeiphoneapps.com/2010/06/how-to-market-your-iphone-ipad-apps/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 18:00:45 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Business]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1949</guid>
		<description><![CDATA[Let Me Guess &#8211; You Are An Awesome Developer But You Know Nothing About Marketing? How To Market iPhone Apps was written by one of our most popular guest bloggers &#8211; Brook Lenox. If you don&#8217;t already know Brook is a marketing samurai who has launched apps to the top of their lists. In his [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2010/06/how-to-market-your-iphone-ipad-apps/" title="Permanent link to How To Market Your iPhone &#038; iPad Apps"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/06/BL_HTMIPA_ebook_250_Tb1.png" width="150" height="226" alt="Post image for How To Market Your iPhone &#038; iPad Apps" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://404e46uou1rj4t7-wmr6rhxr61.hop.clickbank.net/"> </a></p>
<p><a href="http://404e46uou1rj4t7-wmr6rhxr61.hop.clickbank.net/"><strong>Let Me Guess &#8211; You Are An Awesome Developer But You Know Nothing About Marketing?</strong></a></p>
<p><a href="http://404e46uou1rj4t7-wmr6rhxr61.hop.clickbank.net/"> </a></p>
<table align="top">
<tbody>
<tr>
<td></td>
<td>
<div>
<p>How To Market iPhone Apps was written by one of our <strong>most popular guest bloggers</strong> &#8211; Brook Lenox.  If you don&#8217;t already know Brook is a marketing samurai  who has launched apps to the top of their lists.  In his eBook he tells you how.</p>
<p>Brook put <strong>11 apps into the Top 100</strong> list on iTunes.  Top 100 list apps are the ones the everyone buys and <strong>make tons of money</strong>.  This doesn&#8217;t happen by accident, marketing is an art and a science.</p>
</div>
</td>
</tr>
</tbody>
</table>
<h3>Top 5 reasons you should get this eBook:</h3>
<li>You&#8217;ll be given insight into what makes a great app.</li>
<li>It will give you a high level understanding of iPhone app marketing.</li>
<li>It&#8217;s full of practical ideas of ways to market your app (paid &amp; free).</li>
<li>Each chapter has tips, best practices, and homework (possible next steps)!</li>
<li>Finally, the book ends with additional key resources (like where to learn more or how to set up an Admob campaign).</li>
<p>Head over to the <em><a href="http://404e46uou1rj4t7-wmr6rhxr61.hop.clickbank.net/">How To Market iPhone Apps</a></em> website to find out how to get Brook&#8217;s eBook.</p>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;title=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&amp;bodytext=%20%0D%0A%0D%0ALet%20Me%20Guess%20-%20You%20Are%20An%20Awesome%20Developer%20But%20You%20Know%20Nothing%20About%20Marketing%3F%0D%0A%0D%0A%20%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0AHow%20To%20Market%20iPhone%20Apps%20was%20written%20by%20one%20of%20our%20most%20popular%20guest%20bloggers%20-%20Brook%20Lenox.%20%20If%20you%20don%27t%20already%20know%20Brook%20is%20a%20marketing%20" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;title=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&amp;notes=%20%0D%0A%0D%0ALet%20Me%20Guess%20-%20You%20Are%20An%20Awesome%20Developer%20But%20You%20Know%20Nothing%20About%20Marketing%3F%0D%0A%0D%0A%20%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0AHow%20To%20Market%20iPhone%20Apps%20was%20written%20by%20one%20of%20our%20most%20popular%20guest%20bloggers%20-%20Brook%20Lenox.%20%20If%20you%20don%27t%20already%20know%20Brook%20is%20a%20marketing%20" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;t=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;title=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;title=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&amp;annotation=%20%0D%0A%0D%0ALet%20Me%20Guess%20-%20You%20Are%20An%20Awesome%20Developer%20But%20You%20Know%20Nothing%20About%20Marketing%3F%0D%0A%0D%0A%20%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0AHow%20To%20Market%20iPhone%20Apps%20was%20written%20by%20one%20of%20our%20most%20popular%20guest%20bloggers%20-%20Brook%20Lenox.%20%20If%20you%20don%27t%20already%20know%20Brook%20is%20a%20marketing%20" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;title=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=%20%0D%0A%0D%0ALet%20Me%20Guess%20-%20You%20Are%20An%20Awesome%20Developer%20But%20You%20Know%20Nothing%20About%20Marketing%3F%0D%0A%0D%0A%20%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0AHow%20To%20Market%20iPhone%20Apps%20was%20written%20by%20one%20of%20our%20most%20popular%20guest%20bloggers%20-%20Brook%20Lenox.%20%20If%20you%20don%27t%20already%20know%20Brook%20is%20a%20marketing%20" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;t=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;title=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&amp;body=%20%0D%0A%0D%0ALet%20Me%20Guess%20-%20You%20Are%20An%20Awesome%20Developer%20But%20You%20Know%20Nothing%20About%20Marketing%3F%0D%0A%0D%0A%20%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0AHow%20To%20Market%20iPhone%20Apps%20was%20written%20by%20one%20of%20our%20most%20popular%20guest%20bloggers%20-%20Brook%20Lenox.%20%20If%20you%20don%27t%20already%20know%20Brook%20is%20a%20marketing%20" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;title=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F%20How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;t=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&amp;s=%20%0D%0A%0D%0ALet%20Me%20Guess%20-%20You%20Are%20An%20Awesome%20Developer%20But%20You%20Know%20Nothing%20About%20Marketing%3F%0D%0A%0D%0A%20%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0AHow%20To%20Market%20iPhone%20Apps%20was%20written%20by%20one%20of%20our%20most%20popular%20guest%20bloggers%20-%20Brook%20Lenox.%20%20If%20you%20don%27t%20already%20know%20Brook%20is%20a%20marketing%20" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F06%2Fhow-to-market-your-iphone-ipad-apps%2F&amp;t=How%20To%20Market%20Your%20iPhone%20%26%20iPad%20Apps&opener=bm&amp;ei=UTF-8&amp;d=%20%0D%0A%0D%0ALet%20Me%20Guess%20-%20You%20Are%20An%20Awesome%20Developer%20But%20You%20Know%20Nothing%20About%20Marketing%3F%0D%0A%0D%0A%20%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0AHow%20To%20Market%20iPhone%20Apps%20was%20written%20by%20one%20of%20our%20most%20popular%20guest%20bloggers%20-%20Brook%20Lenox.%20%20If%20you%20don%27t%20already%20know%20Brook%20is%20a%20marketing%20" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2010/06/how-to-market-your-iphone-ipad-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Uniquely Identify Your User&#8217;s iPhone, iPad or iPod With UIDevice</title>
		<link>http://howtomakeiphoneapps.com/2010/05/how-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice/</link>
		<comments>http://howtomakeiphoneapps.com/2010/05/how-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice/#comments</comments>
		<pubDate>Tue, 18 May 2010 18:00:58 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Programming]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1865</guid>
		<description><![CDATA[Have you ever wanted a way to uniquely identify your user&#8217;s device? This is something that comes in handy when you are trying to implement a data syncing scheme or if you want to provide unique web based content to your user. If this sounds like something you want to do read on to find [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2010/05/how-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice/" title="Permanent link to How To Uniquely Identify Your User&#8217;s iPhone, iPad or iPod With UIDevice"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/05/barcode-smaller.jpeg" width="250" height="188" alt="Post image for How To Uniquely Identify Your User&#8217;s iPhone, iPad or iPod With UIDevice" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p>Have you ever wanted a way to uniquely identify your user&#8217;s device?  This is something that comes in handy when you are trying to implement a data syncing scheme or if you want to provide unique web based content to your user.  If this sounds like something you want to do read on to find out how.</p>
<h3>Get A Reference To The Current Device</h3>
<p>UIDevice is a class that stores information about the physical device that is running your app.  You use UIDevice to get important information by using the currentDevice function.  This is return a UIDevice object filled with information about the device that is running.  Here is how to get this reference:</p>
<p><a style="display:none" href="http://anyurl.com" rel="tag">CodeProject</a></p>
<pre>
UIDevice *device = [UIDevice currentDevice];
</pre>
<h3>Here Is What UIDevice Will Tell You</h3>
<p>UIDevice objects will store more information that a simple unique identifier.  You may use this object to get all kinds of information that will come in handy in this world of multiple devices.  Here is what you get:</p>
<p><l>
<li>name &#8211; what the user named the device</li>
<li>model &#8211; iPhone, iPod or iPad</li>
<li>systemName &#8211; pretty much &#8220;iPhone OS&#8221;</li>
<li>systemVersion &#8211; tells you what iPhone OS version the system is running</li>
<li>orientation &#8211; what direction the device is currently facing</li>
<li>uniqueIdentifier &#8211; a string unique to each device based on information from the hardware itself</li>
<p>	</l></p>
<h3>uniqueIdentifier Can Be Pretty Useful</h3>
<p>You retrieve all of this information in the same way by accessing the UIDevice object properties.  Here is how to get the unique identifier from the device object we referenced above:</p>
<pre>
NSString *deviceID = device.uniqueIdentifier;
</pre>
<p>And of course you may use this string in the normal ways:</p>
<pre>
NSLog(@"%@", deviceID);
</pre>
<p>You will get something that looks a bit like this:</p>
<p>XXX70A50-ER31-X3X3-BDB2-3ED40EKIUN4D</p>
<h3>Why Do It?</h3>
<p>Of course the why is up to you.  Something that I have thought about is the situation where I want to be able to store user&#8217;s data for syncing purposes.  You may also want to have your users share data or content with other apps, websites and so on.  A simple way to start implementing this functionality could be to use this string to create a folder (or database primary key) to store your user&#8217;s data.  Of course, you will need to do a bit more work on top of this as well.</p>
<p>What do you think &#8211; useful trick?</p>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;title=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&amp;bodytext=Have%20you%20ever%20wanted%20a%20way%20to%20uniquely%20identify%20your%20user%27s%20device%3F%20%20This%20is%20something%20that%20comes%20in%20handy%20when%20you%20are%20trying%20to%20implement%20a%20data%20syncing%20scheme%20or%20if%20you%20want%20to%20provide%20unique%20web%20based%20content%20to%20your%20user.%20%20If%20this%20sounds%20like%20so" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;title=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&amp;notes=Have%20you%20ever%20wanted%20a%20way%20to%20uniquely%20identify%20your%20user%27s%20device%3F%20%20This%20is%20something%20that%20comes%20in%20handy%20when%20you%20are%20trying%20to%20implement%20a%20data%20syncing%20scheme%20or%20if%20you%20want%20to%20provide%20unique%20web%20based%20content%20to%20your%20user.%20%20If%20this%20sounds%20like%20so" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;t=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;title=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;title=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&amp;annotation=Have%20you%20ever%20wanted%20a%20way%20to%20uniquely%20identify%20your%20user%27s%20device%3F%20%20This%20is%20something%20that%20comes%20in%20handy%20when%20you%20are%20trying%20to%20implement%20a%20data%20syncing%20scheme%20or%20if%20you%20want%20to%20provide%20unique%20web%20based%20content%20to%20your%20user.%20%20If%20this%20sounds%20like%20so" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;title=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=Have%20you%20ever%20wanted%20a%20way%20to%20uniquely%20identify%20your%20user%27s%20device%3F%20%20This%20is%20something%20that%20comes%20in%20handy%20when%20you%20are%20trying%20to%20implement%20a%20data%20syncing%20scheme%20or%20if%20you%20want%20to%20provide%20unique%20web%20based%20content%20to%20your%20user.%20%20If%20this%20sounds%20like%20so" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;t=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;title=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&amp;body=Have%20you%20ever%20wanted%20a%20way%20to%20uniquely%20identify%20your%20user%27s%20device%3F%20%20This%20is%20something%20that%20comes%20in%20handy%20when%20you%20are%20trying%20to%20implement%20a%20data%20syncing%20scheme%20or%20if%20you%20want%20to%20provide%20unique%20web%20based%20content%20to%20your%20user.%20%20If%20this%20sounds%20like%20so" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;title=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F%20How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;t=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&amp;s=Have%20you%20ever%20wanted%20a%20way%20to%20uniquely%20identify%20your%20user%27s%20device%3F%20%20This%20is%20something%20that%20comes%20in%20handy%20when%20you%20are%20trying%20to%20implement%20a%20data%20syncing%20scheme%20or%20if%20you%20want%20to%20provide%20unique%20web%20based%20content%20to%20your%20user.%20%20If%20this%20sounds%20like%20so" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice%2F&amp;t=How%20To%20Uniquely%20Identify%20Your%20User%27s%20iPhone%2C%20iPad%20or%20iPod%20With%20UIDevice&opener=bm&amp;ei=UTF-8&amp;d=Have%20you%20ever%20wanted%20a%20way%20to%20uniquely%20identify%20your%20user%27s%20device%3F%20%20This%20is%20something%20that%20comes%20in%20handy%20when%20you%20are%20trying%20to%20implement%20a%20data%20syncing%20scheme%20or%20if%20you%20want%20to%20provide%20unique%20web%20based%20content%20to%20your%20user.%20%20If%20this%20sounds%20like%20so" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2010/05/how-to-uniquely-identify-your-users-iphone-ipad-or-ipod-with-uidevice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Use The iPhone OS UITableView (Video)</title>
		<link>http://howtomakeiphoneapps.com/2010/05/how-to-use-the-iphone-os-uitableview-video/</link>
		<comments>http://howtomakeiphoneapps.com/2010/05/how-to-use-the-iphone-os-uitableview-video/#comments</comments>
		<pubDate>Tue, 11 May 2010 16:50:14 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Programming]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1852</guid>
		<description><![CDATA[CodeProject You see UITableView in all sorts of utility iPhone applications. It is used to display data, lists of items and even to format objects on the touch display. UITableView is one of the things that you can learn that will bring you a ton of leverage in your iPhone app development projects. Today I [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2010/05/how-to-use-the-iphone-os-uitableview-video/" title="Permanent link to How To Use The iPhone OS UITableView (Video)"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/05/IMG0124_11.png" width="300" height="258" alt="Post image for How To Use The iPhone OS UITableView (Video)" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p><a style="display:none" href="http://anyurl.com" rel="tag">CodeProject</a></p>
<p>You see UITableView in all sorts of utility iPhone applications.  It is used to display data, lists of items and even to format objects on the touch display.   UITableView is one of the things that you can learn that will bring you a ton of leverage in your iPhone app development projects.  Today I am going to show you the basics (scroll down to see the video) of using UITableView.</p>
<h3>UITableView in iPhone &#038; iPad Programming</h3>
<p>UITableView uses the delegation pattern that is very common through iPhone SDK.  Generally, the idea is that you will need an object to act of behalf of your UITableView; we will call this object a delegate.  When the system needs to know something, like how many rows are in the table, it will simply &#8220;ask&#8221; the delegate using a specified callback or delegate method.</p>
<p>Delegation is a really useful skill to master and it is used throughout iPhone development.  If you need help with delegation and other iPhone SDK design patterns <a href="http://howtomakeiphoneapps.com/toolbox/" title="Toolbox">check out these resources that will help you</a>.  You may also want <a href="http://howtomakeiphoneapps.com/tutorials/" title="Tutorials">to check out the tutorial section on this website</a>.</p>
<h3>iPhone SDK 3.2 Must Be Installed</h3>
<p>You will need to have iPhone SDK 3.2 installed.  Also, before we start make sure to have created a window-based iPhone application.</p>
<h3>Step By Step</h3>
<p><l>
<li>Create Window-based iPhone application</li>
<li>Add New UITableViewController Subclass</li>
<li>Implement numberOfSectionsInTableView</li>
<li>Implement numberOfRowsInSection</li>
<li>cellForRowAtIndexPath</li>
<li>Import UITableViewController Subclass into your app delegate</li>
<li>Create an instance of your UITableViewController Subclass</li>
<li>Add your UITableViewController Subclass object to the UIWindow</li>
<li>Build and Go</li>
<p>	</l></p>
<h3>Building UITableView Video</h3>
<p><video id = "media" controls="controls"><br />
	<source src="http://d2bhmtpcpvp7li.cloudfront.net/0124 - UITableView/0124 - UITableView - Computer.m4v"><br />
	<source src="http://d2bhmtpcpvp7li.cloudfront.net/0124 - UITableView/0124 - UITableView - iPhone (Cellular).3gp"><br />
	<source src="http://d2bhmtpcpvp7li.cloudfront.net/0124 - UITableView/0124 - UITableView - iPhone.m4v"><br />
	<source src="http://d2bhmtpcpvp7li.cloudfront.net/0124 - UITableView/0124 - UITableView.mov"><br />
</video></p>
<p>Having trouble seeing the video?  <a href="http://d2bhmtpcpvp7li.cloudfront.net/0124 - UITableView/media/0124UITableViewFlash.mp4">Click here to download the mp4 file</a> to your desktop to see the video in your favorite player.</p>
<h3>UITableView Source Code</h3>
<pre>
#import "TableViewOne.h"

@implementation TableViewOne

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return 5;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    cell.textLabel.text = [NSString stringWithFormat:@"%i", indexPath.row];

    return cell;
}

@end
</pre>
<h3>Could You Use UITableView In Your App?</h3>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;title=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&amp;bodytext=CodeProject%0D%0A%0D%0AYou%20see%20UITableView%20in%20all%20sorts%20of%20utility%20iPhone%20applications.%20%20It%20is%20used%20to%20display%20data%2C%20lists%20of%20items%20and%20even%20to%20format%20objects%20on%20the%20touch%20display.%20%20%20UITableView%20is%20one%20of%20the%20things%20that%20you%20can%20learn%20that%20will%20bring%20you%20a%20t" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;title=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&amp;notes=CodeProject%0D%0A%0D%0AYou%20see%20UITableView%20in%20all%20sorts%20of%20utility%20iPhone%20applications.%20%20It%20is%20used%20to%20display%20data%2C%20lists%20of%20items%20and%20even%20to%20format%20objects%20on%20the%20touch%20display.%20%20%20UITableView%20is%20one%20of%20the%20things%20that%20you%20can%20learn%20that%20will%20bring%20you%20a%20t" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;t=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;title=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;title=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&amp;annotation=CodeProject%0D%0A%0D%0AYou%20see%20UITableView%20in%20all%20sorts%20of%20utility%20iPhone%20applications.%20%20It%20is%20used%20to%20display%20data%2C%20lists%20of%20items%20and%20even%20to%20format%20objects%20on%20the%20touch%20display.%20%20%20UITableView%20is%20one%20of%20the%20things%20that%20you%20can%20learn%20that%20will%20bring%20you%20a%20t" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;title=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=CodeProject%0D%0A%0D%0AYou%20see%20UITableView%20in%20all%20sorts%20of%20utility%20iPhone%20applications.%20%20It%20is%20used%20to%20display%20data%2C%20lists%20of%20items%20and%20even%20to%20format%20objects%20on%20the%20touch%20display.%20%20%20UITableView%20is%20one%20of%20the%20things%20that%20you%20can%20learn%20that%20will%20bring%20you%20a%20t" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;t=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;title=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&amp;body=CodeProject%0D%0A%0D%0AYou%20see%20UITableView%20in%20all%20sorts%20of%20utility%20iPhone%20applications.%20%20It%20is%20used%20to%20display%20data%2C%20lists%20of%20items%20and%20even%20to%20format%20objects%20on%20the%20touch%20display.%20%20%20UITableView%20is%20one%20of%20the%20things%20that%20you%20can%20learn%20that%20will%20bring%20you%20a%20t" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;title=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F%20How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;t=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&amp;s=CodeProject%0D%0A%0D%0AYou%20see%20UITableView%20in%20all%20sorts%20of%20utility%20iPhone%20applications.%20%20It%20is%20used%20to%20display%20data%2C%20lists%20of%20items%20and%20even%20to%20format%20objects%20on%20the%20touch%20display.%20%20%20UITableView%20is%20one%20of%20the%20things%20that%20you%20can%20learn%20that%20will%20bring%20you%20a%20t" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fhow-to-use-the-iphone-os-uitableview-video%2F&amp;t=How%20To%20Use%20The%20iPhone%20OS%20UITableView%20%28Video%29&opener=bm&amp;ei=UTF-8&amp;d=CodeProject%0D%0A%0D%0AYou%20see%20UITableView%20in%20all%20sorts%20of%20utility%20iPhone%20applications.%20%20It%20is%20used%20to%20display%20data%2C%20lists%20of%20items%20and%20even%20to%20format%20objects%20on%20the%20touch%20display.%20%20%20UITableView%20is%20one%20of%20the%20things%20that%20you%20can%20learn%20that%20will%20bring%20you%20a%20t" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2010/05/how-to-use-the-iphone-os-uitableview-video/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New iPhone &amp; iPad Programming Tutorials</title>
		<link>http://howtomakeiphoneapps.com/2010/05/new-iphone-ipad-programming-tutorials/</link>
		<comments>http://howtomakeiphoneapps.com/2010/05/new-iphone-ipad-programming-tutorials/#comments</comments>
		<pubDate>Tue, 04 May 2010 18:05:01 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[iPhone Programming]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1843</guid>
		<description><![CDATA[This past week I made some tweaks to this website. You may notice some new visual effects and more organized content. Nothing major but I did want to highlight some of the directions that I have been taking on this website. Here is the low-down H.264 Video Many people have mentioned that it is ironic [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2010/05/new-iphone-ipad-programming-tutorials/" title="Permanent link to New iPhone &#038; iPad Programming Tutorials"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/04/old-mix.jpeg" width="150" height="200" alt="Post image for New iPhone &#038; iPad Programming Tutorials" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p>This past week I made some tweaks to this website.  You may notice some new visual effects and more organized content.  Nothing major but I did want to highlight some of the directions that I have been taking on this website.  Here is the low-down</p>
<h3>H.264 Video</h3>
<p>Many people have mentioned that it is ironic that I some of my screen casts are in Flash.  They are right, streaming video is a vexing problem and Flash works great for everything (but not of course the iPhone).  I have started experimenting with new ways to stream video that you can use from the iPad, iPhone as well as your Mac.</p>
<p>For an example, <a href="http://howtomakeiphoneapps.com/hello-world-iphone-app-with-uiactionsheet/">check out the new Hello World Tutorial</a> that I create last week.  This is a work in progress but I know to have a process in place soon and eventually get all my video up to this new spec.  My feeling is that with the iPad now we can do some serious content distribution using iPhone OS.</p>
<p>At some point in the future I will be discussing the technical details behind this new procedure I am following.</p>
<h3>Live Events/Tutorials Tab Added</h3>
<p>Some of you may know that I have started doing live events like iPhone Boot Camp recently.  Now I am putting dates where I will be doing these training in this tab for people who are interested.  I will also be adding conferences or any other events where Mobile App Mastery will have a presence.</p>
<p>Tutorials are something I have wanted to add to the site for a while.  They have always been here but never featured in a prominent way.</p>
<p>Most of the other changes simply are adding some visual flair: I updated the CSS and change the header a bit as you can see.  What do you think?</p>
<p>Oh Yeah, Here Are the iPhone Programming Tutorials:</p>
<p><a href="http://howtomakeiphoneapps.com/tutorials/">Main Tutorial Page</a></p>
<p><a href="http://howtomakeiphoneapps.com/iphone-programming-tutorial/">iPhone SDK Tutorial</a></p>
<p><a href="http://howtomakeiphoneapps.com/hello-world-iphone-app-with-uiactionsheet/">Hello World iPhone App With UIActionSheet Tutorial</a></p>
<p><a href="http://howtomakeiphoneapps.com/objective-c-tutorial/">Objective-C Tutorial</a></p>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;title=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&amp;bodytext=This%20past%20week%20I%20made%20some%20tweaks%20to%20this%20website.%20%20You%20may%20notice%20some%20new%20visual%20effects%20and%20more%20organized%20content.%20%20Nothing%20major%20but%20I%20did%20want%20to%20highlight%20some%20of%20the%20directions%20that%20I%20have%20been%20taking%20on%20this%20website.%20%20Here%20is%20the%20low-down%0D%0AH" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;title=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&amp;notes=This%20past%20week%20I%20made%20some%20tweaks%20to%20this%20website.%20%20You%20may%20notice%20some%20new%20visual%20effects%20and%20more%20organized%20content.%20%20Nothing%20major%20but%20I%20did%20want%20to%20highlight%20some%20of%20the%20directions%20that%20I%20have%20been%20taking%20on%20this%20website.%20%20Here%20is%20the%20low-down%0D%0AH" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;t=New%20iPhone%20%26%20iPad%20Programming%20Tutorials" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;title=New%20iPhone%20%26%20iPad%20Programming%20Tutorials" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;title=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&amp;annotation=This%20past%20week%20I%20made%20some%20tweaks%20to%20this%20website.%20%20You%20may%20notice%20some%20new%20visual%20effects%20and%20more%20organized%20content.%20%20Nothing%20major%20but%20I%20did%20want%20to%20highlight%20some%20of%20the%20directions%20that%20I%20have%20been%20taking%20on%20this%20website.%20%20Here%20is%20the%20low-down%0D%0AH" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;title=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=This%20past%20week%20I%20made%20some%20tweaks%20to%20this%20website.%20%20You%20may%20notice%20some%20new%20visual%20effects%20and%20more%20organized%20content.%20%20Nothing%20major%20but%20I%20did%20want%20to%20highlight%20some%20of%20the%20directions%20that%20I%20have%20been%20taking%20on%20this%20website.%20%20Here%20is%20the%20low-down%0D%0AH" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;t=New%20iPhone%20%26%20iPad%20Programming%20Tutorials" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;title=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&amp;body=This%20past%20week%20I%20made%20some%20tweaks%20to%20this%20website.%20%20You%20may%20notice%20some%20new%20visual%20effects%20and%20more%20organized%20content.%20%20Nothing%20major%20but%20I%20did%20want%20to%20highlight%20some%20of%20the%20directions%20that%20I%20have%20been%20taking%20on%20this%20website.%20%20Here%20is%20the%20low-down%0D%0AH" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;title=New%20iPhone%20%26%20iPad%20Programming%20Tutorials" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F%20New%20iPhone%20%26%20iPad%20Programming%20Tutorials" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;t=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&amp;s=This%20past%20week%20I%20made%20some%20tweaks%20to%20this%20website.%20%20You%20may%20notice%20some%20new%20visual%20effects%20and%20more%20organized%20content.%20%20Nothing%20major%20but%20I%20did%20want%20to%20highlight%20some%20of%20the%20directions%20that%20I%20have%20been%20taking%20on%20this%20website.%20%20Here%20is%20the%20low-down%0D%0AH" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F05%2Fnew-iphone-ipad-programming-tutorials%2F&amp;t=New%20iPhone%20%26%20iPad%20Programming%20Tutorials&opener=bm&amp;ei=UTF-8&amp;d=This%20past%20week%20I%20made%20some%20tweaks%20to%20this%20website.%20%20You%20may%20notice%20some%20new%20visual%20effects%20and%20more%20organized%20content.%20%20Nothing%20major%20but%20I%20did%20want%20to%20highlight%20some%20of%20the%20directions%20that%20I%20have%20been%20taking%20on%20this%20website.%20%20Here%20is%20the%20low-down%0D%0AH" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2010/05/new-iphone-ipad-programming-tutorials/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Video Demo: How you get pictures into the iPhone Simulator</title>
		<link>http://howtomakeiphoneapps.com/2010/04/video-demo-how-you-get-pictures-into-the-iphone-simulator-2/</link>
		<comments>http://howtomakeiphoneapps.com/2010/04/video-demo-how-you-get-pictures-into-the-iphone-simulator-2/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 12:53:11 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1757</guid>
		<description><![CDATA[This was a problem I had early on &#8211; most of my apps required use of the camera or the photo library. For the longest time I believed that you couldn&#8217;t test the photo library on the simulator. I was wrong, it is actually pretty easy to get pictures into the simulator for testing. Here [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2010/04/video-demo-how-you-get-pictures-into-the-iphone-simulator-2/" title="Permanent link to Video Demo: How you get pictures into the iPhone Simulator"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/04/Old-Time-Photo.jpg" width="307" height="391" alt="Post image for Video Demo: How you get pictures into the iPhone Simulator" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p>This was a problem I had early on &#8211; most of my apps required use of the camera or the photo library.  For the longest time I believed that you couldn&#8217;t test the photo library on the simulator.  I was wrong, it is actually pretty easy to get pictures into the simulator for testing.</p>
<p><a href="http://howtomakeiphoneapps.com/2009/01/video-demo-how-you-get-pictures-into-the-iphone-simulator/">Here is a video demo of me doing just that.</a></p>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;title=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&amp;bodytext=This%20was%20a%20problem%20I%20had%20early%20on%20-%20most%20of%20my%20apps%20required%20use%20of%20the%20camera%20or%20the%20photo%20library.%20%20For%20the%20longest%20time%20I%20believed%20that%20you%20couldn%27t%20test%20the%20photo%20library%20on%20the%20simulator.%20%20I%20was%20wrong%2C%20it%20is%20actually%20pretty%20easy%20to%20get%20pictures%20" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;title=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&amp;notes=This%20was%20a%20problem%20I%20had%20early%20on%20-%20most%20of%20my%20apps%20required%20use%20of%20the%20camera%20or%20the%20photo%20library.%20%20For%20the%20longest%20time%20I%20believed%20that%20you%20couldn%27t%20test%20the%20photo%20library%20on%20the%20simulator.%20%20I%20was%20wrong%2C%20it%20is%20actually%20pretty%20easy%20to%20get%20pictures%20" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;t=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;title=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;title=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&amp;annotation=This%20was%20a%20problem%20I%20had%20early%20on%20-%20most%20of%20my%20apps%20required%20use%20of%20the%20camera%20or%20the%20photo%20library.%20%20For%20the%20longest%20time%20I%20believed%20that%20you%20couldn%27t%20test%20the%20photo%20library%20on%20the%20simulator.%20%20I%20was%20wrong%2C%20it%20is%20actually%20pretty%20easy%20to%20get%20pictures%20" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;title=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=This%20was%20a%20problem%20I%20had%20early%20on%20-%20most%20of%20my%20apps%20required%20use%20of%20the%20camera%20or%20the%20photo%20library.%20%20For%20the%20longest%20time%20I%20believed%20that%20you%20couldn%27t%20test%20the%20photo%20library%20on%20the%20simulator.%20%20I%20was%20wrong%2C%20it%20is%20actually%20pretty%20easy%20to%20get%20pictures%20" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;t=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;title=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&amp;body=This%20was%20a%20problem%20I%20had%20early%20on%20-%20most%20of%20my%20apps%20required%20use%20of%20the%20camera%20or%20the%20photo%20library.%20%20For%20the%20longest%20time%20I%20believed%20that%20you%20couldn%27t%20test%20the%20photo%20library%20on%20the%20simulator.%20%20I%20was%20wrong%2C%20it%20is%20actually%20pretty%20easy%20to%20get%20pictures%20" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;title=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F%20Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;t=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&amp;s=This%20was%20a%20problem%20I%20had%20early%20on%20-%20most%20of%20my%20apps%20required%20use%20of%20the%20camera%20or%20the%20photo%20library.%20%20For%20the%20longest%20time%20I%20believed%20that%20you%20couldn%27t%20test%20the%20photo%20library%20on%20the%20simulator.%20%20I%20was%20wrong%2C%20it%20is%20actually%20pretty%20easy%20to%20get%20pictures%20" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F04%2Fvideo-demo-how-you-get-pictures-into-the-iphone-simulator-2%2F&amp;t=Video%20Demo%3A%20How%20you%20get%20pictures%20into%20the%20iPhone%20Simulator&opener=bm&amp;ei=UTF-8&amp;d=This%20was%20a%20problem%20I%20had%20early%20on%20-%20most%20of%20my%20apps%20required%20use%20of%20the%20camera%20or%20the%20photo%20library.%20%20For%20the%20longest%20time%20I%20believed%20that%20you%20couldn%27t%20test%20the%20photo%20library%20on%20the%20simulator.%20%20I%20was%20wrong%2C%20it%20is%20actually%20pretty%20easy%20to%20get%20pictures%20" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2010/04/video-demo-how-you-get-pictures-into-the-iphone-simulator-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Make An Egg Timer For Your iPhone</title>
		<link>http://howtomakeiphoneapps.com/2010/03/how-to-make-an-egg-timer-for-your-iphone/</link>
		<comments>http://howtomakeiphoneapps.com/2010/03/how-to-make-an-egg-timer-for-your-iphone/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 15:18:28 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Programming]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1754</guid>
		<description><![CDATA[It seems like I use my iPhone all the time as a simple timer. I time how long it takes to cook a steak on the grill, when the pizza is ready to be picked up and how long I should stay on the treadmill to work off all the steak and pizza I eat. [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2010/03/how-to-make-an-egg-timer-for-your-iphone/" title="Permanent link to How To Make An Egg Timer For Your iPhone"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/03/eggtimer1.jpg" width="216" height="333" alt="Post image for How To Make An Egg Timer For Your iPhone" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p>It seems like I use my iPhone all the time as a simple timer.  I time how long it takes to cook a steak on the grill, when the pizza is ready to be picked up and how long I should stay on the treadmill to work off all the steak and pizza I eat.</p>
<p><a style="display: none;" rel="tag" href="http://anyurl.com">CodeProject</a></p>
<p>So for this post I thought it would be fun to see how to create a timer from scratch specifically for one task like cooking an egg.  Of course, I am betting that your app could use this function as well especially if you would like to do something like animate a sequence of images or periodically update a RSS feed.</p>
<h3>What We Need Is Called NSTimer</h3>
<p>The class that we will need to use to create our egg timer is called NSTimer.  This class works like it sounds, you use it to time things.  What ends up happening is that you create a timer and then have it perform some action at an interval that you specify.</p>
<h3>Egg Timer App Setup Notes</h3>
<p>Before we move on I just want to make sure you have an idea of the plumbing I set up for this exercise.  What I did was create a View-Based application; then I added a UIImageView, UIButton and a UILabel to the View.  I also set some properties to make the app look a bit more unique and connected the appropriate IBOutlets.  The final thing I did before working with NSTimer was I coded and connected an IBAction called pressButton which start the timer when the user touches the UIButton.</p>
<p>Here is what the app will look like:</p>
<p><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/03/eggtimer2.png" alt="default_button.png" /></p>
<p>Here is the interface file for the UIViewController I started with for this project with the IBOutlets and IBAction:</p>
<pre>#import &lt;UIKit/UIKit.h&gt;

@interface EggTimerViewController : UIViewController {
	IBOutlet UILabel *label;
	IBOutlet UIButton *button;
}

@property(nonatomic, retain) IBOutlet UILabel *label;
@property(nonatomic, retain) IBOutlet UIButton *button;

-(IBAction)pressButton;

@end</pre>
<p>Finally, here is the implementation:</p>
<pre>#import "EggTimerViewController.h"

@implementation EggTimerViewController
@synthesize label, button;

- (void)dealloc {
	[label release];
	[button release];
	[super dealloc];
}

-(IBAction)pressButton{

}

@end</pre>
<h3>Take Action Each Time</h3>
<p>Usually you will want something to happen at a set interval when you are working with apps like the egg timer.  It could be to simply update the GUI each second or you may have something bigger in mind.  Try to imagine your timer (which I know we haven&#8217;t create quite yet) is out there in your app sending a signal each second (or whatever your time interval will be).  You will want something to respond to these signals and do something useful.</p>
<p>We can implement this useful behavior by writing some code and wrapping it up in a method.  For my egg timer I will simply put the following code in a method called timerFires:</p>
<pre>- (void) timerFires{
	if(i &gt; 0){
		i--;
		label.text = [NSString stringWithFormat:@"%i", i];
	}
	else{
		label.text = @"The egg is ready";
		[timer release];
		timer = nil;
	}
}</pre>
<p>What this method is doing is displaying a count in the UILabel, decreasing the value of the counter variable &#8220;i&#8221; until it reachers zero.  Once the counter reaches zero the app will display a message that the egg is ready and the timer will be released.</p>
<p>NOTE: astute readers will note that I am using an integer &#8220;i&#8221; and an NSTimer &#8220;timer here.  These are declared at the top of the UIViewController code file right under the @synthesize statement like so:</p>
<pre>#import "EggTimerViewController.h"

@implementation EggTimerViewController
@synthesize label, button;
<strong>NSTimer *timer;
int i;</strong>
...</pre>
<h3>Set The Timer In Motion</h3>
<p>Now that we have something coded which the timer may use to take action we need to actually create the NSTimer object and get it to start sending out its messages.  We will put the code to do that in the pressButton method:</p>
<pre>-(IBAction)pressButton{
	i = 180;
	timer = [NSTimer scheduledTimerWithTimeInterval:1
	                                         target:self
	                                       selector:@selector(timerFires)
	                                       userInfo:nil
	                                        repeats:YES];
	[timer fire];
}</pre>
<p>If you test this code now you will see the counter display on your app that will start to decrease when you press the button on the UI.  Let&#8217;s go and point out some of the details now&#8230;</p>
<h4>i = 180;</h4>
<p>We set the counter variable &#8220;i&#8221; to 180 because that is how many seconds it takes to boil an egg.</p>
<h4>timer = [NSTimer scheduledTimerWithTimeInterval:1</h4>
<p>Next we start to create our NSTimer object using the scheduledTimerWithTimeInterval function.  The first parameter we will send along with this function is a number that will indicate the time interval we want our NSTimer to use.  Here I set &#8220;1&#8243; because I want it to do something each second.  You can use decimal places if you want to increase or decrease the timing in your own app.</p>
<h4>target:self</h4>
<h4>selector:@selector(timerFires)</h4>
<p>The next two parameters indicate what method will fire for each interval the timer fires.  This follows the typical target-action pattern used throughout iPhone OS development.</p>
<h4>userInfo:nil</h4>
<p>You may simply pass nil for the userInfo parameter here since you generally will not need to use this.</p>
<h4>repeats:YES</h4>
<p>Setting this to NO will only have the NSTimer fire once.  You will usually keep this YES unless you are using NSTimer to create a scheduled task (another use of NSTimer).</p>
<h3>That&#8217;s It &#8211; The Egg Is Ready!</h3>
<p>So that is how you can use NSTimer to create your own specialized stop watches or to simply using timing to add animations or other pizzazz to your app.</p>
<p style="text-align: center;"><strong>What Else Could You Use NSTimer For?</strong></p>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;title=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&amp;bodytext=It%20seems%20like%20I%20use%20my%20iPhone%20all%20the%20time%20as%20a%20simple%20timer.%20%20I%20time%20how%20long%20it%20takes%20to%20cook%20a%20steak%20on%20the%20grill%2C%20when%20the%20pizza%20is%20ready%20to%20be%20picked%20up%20and%20how%20long%20I%20should%20stay%20on%20the%20treadmill%20to%20work%20off%20all%20the%20steak%20and%20pizza%20I%20eat.%0D%0A%0D%0ACo" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;title=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&amp;notes=It%20seems%20like%20I%20use%20my%20iPhone%20all%20the%20time%20as%20a%20simple%20timer.%20%20I%20time%20how%20long%20it%20takes%20to%20cook%20a%20steak%20on%20the%20grill%2C%20when%20the%20pizza%20is%20ready%20to%20be%20picked%20up%20and%20how%20long%20I%20should%20stay%20on%20the%20treadmill%20to%20work%20off%20all%20the%20steak%20and%20pizza%20I%20eat.%0D%0A%0D%0ACo" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;t=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;title=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;title=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&amp;annotation=It%20seems%20like%20I%20use%20my%20iPhone%20all%20the%20time%20as%20a%20simple%20timer.%20%20I%20time%20how%20long%20it%20takes%20to%20cook%20a%20steak%20on%20the%20grill%2C%20when%20the%20pizza%20is%20ready%20to%20be%20picked%20up%20and%20how%20long%20I%20should%20stay%20on%20the%20treadmill%20to%20work%20off%20all%20the%20steak%20and%20pizza%20I%20eat.%0D%0A%0D%0ACo" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;title=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=It%20seems%20like%20I%20use%20my%20iPhone%20all%20the%20time%20as%20a%20simple%20timer.%20%20I%20time%20how%20long%20it%20takes%20to%20cook%20a%20steak%20on%20the%20grill%2C%20when%20the%20pizza%20is%20ready%20to%20be%20picked%20up%20and%20how%20long%20I%20should%20stay%20on%20the%20treadmill%20to%20work%20off%20all%20the%20steak%20and%20pizza%20I%20eat.%0D%0A%0D%0ACo" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;t=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;title=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&amp;body=It%20seems%20like%20I%20use%20my%20iPhone%20all%20the%20time%20as%20a%20simple%20timer.%20%20I%20time%20how%20long%20it%20takes%20to%20cook%20a%20steak%20on%20the%20grill%2C%20when%20the%20pizza%20is%20ready%20to%20be%20picked%20up%20and%20how%20long%20I%20should%20stay%20on%20the%20treadmill%20to%20work%20off%20all%20the%20steak%20and%20pizza%20I%20eat.%0D%0A%0D%0ACo" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;title=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F%20How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;t=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&amp;s=It%20seems%20like%20I%20use%20my%20iPhone%20all%20the%20time%20as%20a%20simple%20timer.%20%20I%20time%20how%20long%20it%20takes%20to%20cook%20a%20steak%20on%20the%20grill%2C%20when%20the%20pizza%20is%20ready%20to%20be%20picked%20up%20and%20how%20long%20I%20should%20stay%20on%20the%20treadmill%20to%20work%20off%20all%20the%20steak%20and%20pizza%20I%20eat.%0D%0A%0D%0ACo" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-make-an-egg-timer-for-your-iphone%2F&amp;t=How%20To%20Make%20An%20Egg%20Timer%20For%20Your%20iPhone&opener=bm&amp;ei=UTF-8&amp;d=It%20seems%20like%20I%20use%20my%20iPhone%20all%20the%20time%20as%20a%20simple%20timer.%20%20I%20time%20how%20long%20it%20takes%20to%20cook%20a%20steak%20on%20the%20grill%2C%20when%20the%20pizza%20is%20ready%20to%20be%20picked%20up%20and%20how%20long%20I%20should%20stay%20on%20the%20treadmill%20to%20work%20off%20all%20the%20steak%20and%20pizza%20I%20eat.%0D%0A%0D%0ACo" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2010/03/how-to-make-an-egg-timer-for-your-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Do Amazingly Simple Searches With NSArray &amp; NSPredicate</title>
		<link>http://howtomakeiphoneapps.com/2010/03/how-to-do-amazingly-simple-searches-with-nsarray-nspredicate/</link>
		<comments>http://howtomakeiphoneapps.com/2010/03/how-to-do-amazingly-simple-searches-with-nsarray-nspredicate/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 13:43:14 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Programming]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1730</guid>
		<description><![CDATA[Cocoa-Touch ships with an super-useful class that will help you search through your lists of objects just like they were coming from a database. The class is called NSPredicate which also works with Core Data. This is very powerful stuff, especially what you are working with data intensive applications. CodeProject Here Is How NSPredicate Works [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2010/03/how-to-do-amazingly-simple-searches-with-nsarray-nspredicate/" title="Permanent link to How To Do Amazingly Simple Searches With NSArray &#038; NSPredicate"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/03/SearchingRobot.jpeg" width="200" height="227" alt="Post image for How To Do Amazingly Simple Searches With NSArray &#038; NSPredicate" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p>Cocoa-Touch ships with an super-useful class that will help you search through your lists of objects just like they were coming from a database.  The class is called NSPredicate which also works with Core Data.  This is very powerful stuff, especially what you are working with data intensive applications.</p>
<p><a style="display: none;" rel="tag" href="http://anyurl.com">CodeProject</a></p>
<h3>Here Is How NSPredicate Works</h3>
<p>First off, keep in mind that generally we are using NSArray to manage lists of objects in our apps.  The objects that NSArray stores for us are made up of properties like name, length and whatever is required for the objects in question.  NSPredicate works by defining queries that select objects from an array based on the properties of the objects in the array.</p>
<p>Here are the steps required to search arrays with NSPredicate:</p>
<li>Find or create an NSArray full of objects with interesting properties</li>
<li>Create an NSPredicate object with the search query that you want to use</li>
<li>You can use this NSPredicate object to either filter the array or create a new array with a subset of data</li>
<p>Essentially, these three steps are all it takes to filter an array.  Of course, you will need some other pieces in place to do some meaningful work.  Next, I will show you a concrete example of using NSPredicate with a custom class.</p>
<h3>NSPredicate Search Example</h3>
<h4>Here Is The Type Of Object We Will Query</h4>
<p>The first thing I did for this example was to create a custom class called RowOfData that could correspond to an individual row of data in a database.</p>
<p>NOTE: this does not mean that you really use SQL per-say with NSPredicate &#8211; the types of queries are more like a regex style.  <a title="Mac Dev Center: Predicate Programming Guide: Predicate Format String Syntax" href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html">Check this Apple documentation</a> for more details on what types of queries are available to you.</p>
<p>Anyway, here is the class definition for RowOfData:</p>
<pre>#import &lt;Foundation/Foundation.h&gt;

@interface RowOfData : NSObject {
	int primaryKey;
	NSString *name;
	NSString *job;
	NSNumber *salary;
}

@property(nonatomic, assign) int primaryKey;
@property(nonatomic, retain) NSString *name;
@property(nonatomic, retain) NSString *job;
@property(nonatomic, retain) NSNumber *salary;

@end</pre>
<p>Each RowOfData object in the array we are about to create represents an individual and details about his or her job and salary.</p>
<h4>Create Your NSArray &amp; Fill It With RowOfData Objects</h4>
<p>In effect, we are creating a list of objects that is a bit like a database table.  Note here that listOfItems is declared as an NSMutableArray at the top of the file where this code would be located since it needs to stay in scope though-out the lifecycle of objects made from the class:</p>
<pre>listOfItems = [[NSMutableArray alloc] init];
RowOfData *row;
row = [[RowOfData alloc] init];
row.primaryKey = 0;
row.name = @"Tom";
row.job = @"Car Salesman";
row.salary = [NSNumber numberWithDouble:43900];
[listOfItems addObject:row];
row = [[RowOfData alloc] init];
row.primaryKey = 1;
row.name = @"Tina";
row.job = @"Accountant";
row.salary = [NSNumber numberWithDouble:145000];
[listOfItems addObject:row];
row = [[RowOfData alloc] init];
row.primaryKey = 2;
row.name = @"Harry";
row.job = @"Programmer";
row.salary = [NSNumber numberWithDouble:86700];
[listOfItems addObject:row];
row = [[RowOfData alloc] init];
row.primaryKey = 3;
row.name = @"Sally";
row.job = @"Poker Player";
row.salary = [NSNumber numberWithDouble:98000];
[listOfItems addObject:row];
row = [[RowOfData alloc] init];
row.primaryKey = 4;
row.name = @"Phil";
row.job = @"Programmer";
row.salary = [NSNumber numberWithDouble:2500000];
[listOfItems addObject:row];</pre>
<p>To summarize, we create an array and then create each object and add each object to the array.  Here is what the results would look like if we were to present this array in a table view:</p>
<p><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/03/IMG0108_11.png" alt="default_button.png" /></p>
<h4>Get A Subset Of Data Instead!</h4>
<p>So here is what you have been waiting for.  To display a subset of the dataset you would need to code an NSPredicate using a query string.  For instance, if we wanted to find out who in our dataset were programmers we could do something like this:</p>
<pre>NSPredicate *predicate = [NSPredicate predicateWithFormat:@"job == 'Programmer'"];
[listOfItems filterUsingPredicate:predicate];</pre>
<p>Pretty simple huh?  All you need to do is create the NSPredicate with our query and send the filterUsingPredicate message to your array using the NSPredicate object as an argument.  If we tack this query to the end of our code and again run an app using a table view it would look like this:</p>
<p><img src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/03/IMG0108_2.png" alt="default_button.png" /></p>
<h4>More NSPredicate Query Examples:</h4>
<p>Remember that we can do this because &#8220;job&#8221; is a property of the objects contain in the array.  You can query based on other properties as well.  Here are some examples of what you can do:</p>
<p>Find out who makes at least $100,000 per year:</p>
<pre>NSPredicate *predicate = [NSPredicate predicateWithFormat:@"salary &gt;= 100000"];
[listOfItems filterUsingPredicate:predicate];</pre>
<p>Find everyone who has a name that begins with &#8220;T&#8221;:</p>
<pre>NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name BEGINSWITH 'T'"];
[listOfItems filterUsingPredicate:predicate];</pre>
<p>I could throw examples at you all day but ultimately this will be useful when you can apply it the objects you use in your own apps.  <a title="Mac Dev Center: Predicate Programming Guide: Predicate Format String Syntax" href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html">Check this Apple documentation</a> for a complete list of the functions you can use with NSPredicate.</p>
<p style="text-align: left;"><a href="http://mobileappmastery.com/getcore/?utm_source=howtomakeiphoneapps&amp;utm_medium=blog&amp;utm_campaign=ecourse1"><br />
</a>Another nice touch is that this method may be used with classes other than NSArray.  One important use of NSPredicate is with Core Data.  You can actually use NSPredicate to query the underlying data store managed by Core Data.  This gives you a lot of powerful and efficient data management techniques right out of the box.</p>
<h3>Do You See A Use Case For NSPredicate In Your Next App?</h3>
<div id="standout">
<h1>Here Is How To Fast Track Your Objective-C Programming Skills&#8230;</h1>
<p><br/></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/02WcfTD0ntQ&amp;hl=en_US&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/02WcfTD0ntQ&amp;hl=en_US&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://mobileappmastery.com/learntoprogram/?utm_source=blog&amp;utm_medium=inpostad&amp;utm_campaign=traffic"><img class="alignright size-medium wp-image-2022" title="DVDCoverSetup" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/DVDCoverSetup-150x130.png" alt="" width="150" height="130" /></a><a href="http://mobileappmastery.com/learntoprogram/?utm_source=blog&amp;utm_medium=inpostad&amp;utm_campaign=traffic">Click here </a>or the box to the right to access to your online workshop now&#8230;</p>
<p>Each lesson comes packed with comprehensive video, source code and text. When appropriate I include hands-on exercises. Check out the list below to see what is specifically covered in each lesson:</p>
<h3>Module 1 &#8211; Getting Started With iPhone App Development</h3>
<p>- Lesson 1 &#8211; Overview of iPhone OS<br />
- Lesson 2 &#8211; Introduction to Tools: XCode, Interface Builder &amp; iPhone Simulator<br />
- Lesson 3 &#8211; Your First App<br />
- Lesson 4 &#8211; Super-Charge XCode</p>
<h3>Module 2 &#8211; Learn How to Program in C</h3>
<p>- Lesson 1 &#8211; What is Programming?<br />
- Lesson 2 &#8211; C Programming Basics and Specifics<br />
- Lesson 3 &#8211; Functions<br />
- Lesson 4 &#8211; Variables and Arrays<br />
- Lesson 5 &#8211; Program Flow<br />
- Lesson 6 &#8211; Loops<br />
- Lesson 7 &#8211; Complex Data with Struct<br />
- Lesson 8 &#8211; Putting It All Together</p>
<h3>Module 3 &#8211; Master Object Oriented Programming With Objective-C</h3>
<p>- Lesson 1 &#8211; What is Object Oriented Programming?<br />
- Lesson 2 &#8211; Objects<br />
- Lesson 3 &#8211; More Strings, Lists and the For Each Loop<br />
- Lesson 4 &#8211; Memory Management<br />
- Lesson 5 &#8211; Designing Your Own Classes<br />
- Lesson 6 &#8211; Extending Classes With Categories<br />
- Lesson 7 &#8211; Protocols &amp; Key-Value Coding</p>
<h3>Module 4 &#8211; No-BS Cocoa-Touch With iPhone SDK</h3>
<p>- Lesson 1 &#8211; Overview of Cocoa-Touch + Model-View-Controller<br />
- Lesson 2 &#8211; Using Interface Builder (The View)<br />
- Lesson 3 &#8211; Target-Action and the View in Code<br />
- Lesson 4 &#8211; Delegation<br />
- Lesson 5 &#8211; Super-Charging Your View With Interface Builder<br />
- Lesson 6 &#8211; Model &amp; App Architecture</p>
<p><a href="http://mobileappmastery.com/learntoprogram/?utm_source=blog&amp;utm_medium=inpostad&amp;utm_campaign=traffic"><img class="alignright size-medium wp-image-2022" title="DVDCoverSetup" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/DVDCoverSetup-150x130.png" alt="" width="150" height="130" /></a><a href="http://mobileappmastery.com/learntoprogram/?utm_source=blog&amp;utm_medium=inpostad&amp;utm_campaign=traffic">Click here </a>or the box to the right to access to your online workshop now</p>
</div>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;title=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&amp;bodytext=Cocoa-Touch%20ships%20with%20an%20super-useful%20class%20that%20will%20help%20you%20search%20through%20your%20lists%20of%20objects%20just%20like%20they%20were%20coming%20from%20a%20database.%20%20The%20class%20is%20called%20NSPredicate%20which%20also%20works%20with%20Core%20Data.%20%20This%20is%20very%20powerful%20stuff%2C%20especiall" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;title=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&amp;notes=Cocoa-Touch%20ships%20with%20an%20super-useful%20class%20that%20will%20help%20you%20search%20through%20your%20lists%20of%20objects%20just%20like%20they%20were%20coming%20from%20a%20database.%20%20The%20class%20is%20called%20NSPredicate%20which%20also%20works%20with%20Core%20Data.%20%20This%20is%20very%20powerful%20stuff%2C%20especiall" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;t=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;title=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;title=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&amp;annotation=Cocoa-Touch%20ships%20with%20an%20super-useful%20class%20that%20will%20help%20you%20search%20through%20your%20lists%20of%20objects%20just%20like%20they%20were%20coming%20from%20a%20database.%20%20The%20class%20is%20called%20NSPredicate%20which%20also%20works%20with%20Core%20Data.%20%20This%20is%20very%20powerful%20stuff%2C%20especiall" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;title=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=Cocoa-Touch%20ships%20with%20an%20super-useful%20class%20that%20will%20help%20you%20search%20through%20your%20lists%20of%20objects%20just%20like%20they%20were%20coming%20from%20a%20database.%20%20The%20class%20is%20called%20NSPredicate%20which%20also%20works%20with%20Core%20Data.%20%20This%20is%20very%20powerful%20stuff%2C%20especiall" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;t=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;title=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&amp;body=Cocoa-Touch%20ships%20with%20an%20super-useful%20class%20that%20will%20help%20you%20search%20through%20your%20lists%20of%20objects%20just%20like%20they%20were%20coming%20from%20a%20database.%20%20The%20class%20is%20called%20NSPredicate%20which%20also%20works%20with%20Core%20Data.%20%20This%20is%20very%20powerful%20stuff%2C%20especiall" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;title=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F%20How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;t=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&amp;s=Cocoa-Touch%20ships%20with%20an%20super-useful%20class%20that%20will%20help%20you%20search%20through%20your%20lists%20of%20objects%20just%20like%20they%20were%20coming%20from%20a%20database.%20%20The%20class%20is%20called%20NSPredicate%20which%20also%20works%20with%20Core%20Data.%20%20This%20is%20very%20powerful%20stuff%2C%20especiall" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2010%2F03%2Fhow-to-do-amazingly-simple-searches-with-nsarray-nspredicate%2F&amp;t=How%20To%20Do%20Amazingly%20Simple%20Searches%20With%20NSArray%20%26%20NSPredicate&opener=bm&amp;ei=UTF-8&amp;d=Cocoa-Touch%20ships%20with%20an%20super-useful%20class%20that%20will%20help%20you%20search%20through%20your%20lists%20of%20objects%20just%20like%20they%20were%20coming%20from%20a%20database.%20%20The%20class%20is%20called%20NSPredicate%20which%20also%20works%20with%20Core%20Data.%20%20This%20is%20very%20powerful%20stuff%2C%20especiall" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2010/03/how-to-do-amazingly-simple-searches-with-nsarray-nspredicate/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How To Use UIScrollView in Your iPhone App</title>
		<link>http://howtomakeiphoneapps.com/2009/12/how-to-use-uiscrollview-in-your-iphone-app/</link>
		<comments>http://howtomakeiphoneapps.com/2009/12/how-to-use-uiscrollview-in-your-iphone-app/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 18:15:26 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Programming]]></category>
		<category><![CDATA[Cocoa-Touch]]></category>
		<category><![CDATA[how to make iphone apps]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[UIScrollView]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1644</guid>
		<description><![CDATA[Sometimes you would like to be able to display an image or view that is larger than the iPhone or iPod screen. UIScrollView gives you this ability plus the feature of zooming using the pinch gesture. This video will show you how to implement this in your own iPhone app. Source Code follows video. Implementing [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2009/12/how-to-use-uiscrollview-in-your-iphone-app/" title="Permanent link to How To Use UIScrollView in Your iPhone App"><img class="post_image alignright remove_bottom_margin" src="http://howtomakeiphoneapps.com/wp-content/uploads/2009/12/How-To-Code.jpg" width="393" height="305" alt="Post image for How To Use UIScrollView in Your iPhone App" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=Cocoa-Touch,how+to+make+iphone+apps,Images,UIScrollView" height="61" width="50" /><br />
			</a>
		</div>
<p>Sometimes you would like to be able to display an image or view that is larger than the iPhone or iPod screen.  UIScrollView gives you this ability plus the feature of zooming using the pinch gesture.  This video will show you how to implement this in your own iPhone app.  Source Code follows video.</p>
<p>
	<object width="600" height="375"><param name="movie" value="http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/mp4h264player.swf"></param><param name="quality" value="high"></param><param name="bgcolor" value="#FFFFFF"></param><param name="flashVars" value="thumb=http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/FirstFrame.jpg&#038;containerwidth=600&#038;containerheight=375&#038;content=http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/UseUIScrollView.mp4"></param><param name="allowFullScreen" value="true"></param><param name="scale" value="showall"></param><param name="allowScriptAccess" value="always"></param><param name="base" value="http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/"></param>  <embed src="http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/mp4h264player.swf" quality="high" bgcolor="#FFFFFF" width="600" height="375" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/FirstFrame.jpg&#038;containerwidth=600&#038;containerheight=375&#038;content=http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/UseUIScrollView.mp4" allowFullScreen="true" base="http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/" scale="showall"></embed></object>
</p>
<h3>Implementing UIScrollView in Cocoa-Touch</h3>
<p>This example starts with a View Based Application with the image already in the Resources group.  You can create this yourself using XCode&#8217;s &#8220;New Project&#8221; menu item.</p>
<h3>Add IBOutlets</h3>
<p>Select the view controller interface file and add the scroll view IBOutlet and the image view property:</p>
<pre>
	#import &lt;UIKit/UIKit.h&gt;

	@interface UseScrollViewViewController : UIViewController {
		IBOutlet UIScrollView *scrollView;
		UIImageView *imageView;
	}

	@property (nonatomic, retain) UIScrollView *scrollView;
	@property (nonatomic, retain) UIImageView *imageView;

	@end
</pre>
<p>Finish implementing the IBOutlet and property in the implementation file.</p>
<pre>
	#import "UseScrollViewViewController.h"

	@implementation UseScrollViewViewController
	@synthesize scrollView, imageView;

	- (void)dealloc {
		[super dealloc];
		[imageView release];
		[scrollView release];
	}

	@end
</pre>
<h3>Adopt the Delegate Protocol</h3>
<p>To use UIScrollView we must adopt the UIScrollViewDelegate protocol.  Once we do our view controller may act on behalf of our scroll view.  Simple add this after the UIViewController sublcass: &lt;UIScrollViewDelegate&#038;gt.</p>
<pre>
	#import &lt;UIKit/UIKit.h&gt;

	@interface UseScrollViewViewController : UIViewController&lt;UIScrollViewDelegate&#038;gt {
		IBOutlet UIScrollView *scrollView;
		UIImageView *imageView;
	}

	@property (nonatomic, retain) UIScrollView *scrollView;
	@property (nonatomic, retain) UIImageView *imageView;

	@end
</pre>
<h3>Implement the Delegate Method viewForZoomingInScrollView</h3>
<p>Implementing this method will allow the scroll view to provide the pinching and zooming behavior demonstrated in the video.</p>
<pre>
	#import "UseScrollViewViewController.h"
	@implementation UseScrollViewViewController

...

	- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
		return imageView;
	}

...

	@end
</pre>
<h3>Create the Image View</h3>
<p>The image view will be used to display the image on the view.  This is pretty straightforward: you will simple create the object and set it to the property we defined earlier in the viewDidLoad method.</p>
<pre>
	- (void)viewDidLoad {
	    [super viewDidLoad];
		UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Beer-Sign-On-Wall.jpg"]];
		self.imageView = tempImageView;
		[tempImageView release];

	}
</pre>
<h3>Set the UIScrollView Properties</h3>
<p>Since we are using Interface Builder to add the scroll view we do not need to create it here.  But, we will be setting some of the scroll view properties.  Note that we add the image view to the scroll view&#8217;s subview collection.</p>
<pre>
	- (void)viewDidLoad {

...

		scrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);
		scrollView.maximumZoomScale = 4.0;
		scrollView.minimumZoomScale = 0.75;
		scrollView.clipsToBounds = YES;
		scrollView.delegate = self;
		[scrollView addSubview:imageView];
	}
</pre>
<h3>Add Scroll View in Interface Builder</h3>
<p>Now all you need to do is add your scroll view in interface builder and hook it up to the IBOutlet you defined in the view controller!</p>
<p>Discuss in the comments below!</p>
<div id="standout">
<h1>Here Is How To Fast Track Your Objective-C Programming Skills&#8230;</h1>
<p><br/></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/02WcfTD0ntQ&amp;hl=en_US&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/02WcfTD0ntQ&amp;hl=en_US&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://mobileappmastery.com/learntoprogram/?utm_source=blog&amp;utm_medium=inpostad&amp;utm_campaign=traffic"><img class="alignright size-medium wp-image-2022" title="DVDCoverSetup" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/DVDCoverSetup-150x130.png" alt="" width="150" height="130" /></a><a href="http://mobileappmastery.com/learntoprogram/?utm_source=blog&amp;utm_medium=inpostad&amp;utm_campaign=traffic">Click here </a>or the box to the right to access to your online workshop now&#8230;</p>
<p>Each lesson comes packed with comprehensive video, source code and text. When appropriate I include hands-on exercises. Check out the list below to see what is specifically covered in each lesson:</p>
<h3>Module 1 &#8211; Getting Started With iPhone App Development</h3>
<p>- Lesson 1 &#8211; Overview of iPhone OS<br />
- Lesson 2 &#8211; Introduction to Tools: XCode, Interface Builder &amp; iPhone Simulator<br />
- Lesson 3 &#8211; Your First App<br />
- Lesson 4 &#8211; Super-Charge XCode</p>
<h3>Module 2 &#8211; Learn How to Program in C</h3>
<p>- Lesson 1 &#8211; What is Programming?<br />
- Lesson 2 &#8211; C Programming Basics and Specifics<br />
- Lesson 3 &#8211; Functions<br />
- Lesson 4 &#8211; Variables and Arrays<br />
- Lesson 5 &#8211; Program Flow<br />
- Lesson 6 &#8211; Loops<br />
- Lesson 7 &#8211; Complex Data with Struct<br />
- Lesson 8 &#8211; Putting It All Together</p>
<h3>Module 3 &#8211; Master Object Oriented Programming With Objective-C</h3>
<p>- Lesson 1 &#8211; What is Object Oriented Programming?<br />
- Lesson 2 &#8211; Objects<br />
- Lesson 3 &#8211; More Strings, Lists and the For Each Loop<br />
- Lesson 4 &#8211; Memory Management<br />
- Lesson 5 &#8211; Designing Your Own Classes<br />
- Lesson 6 &#8211; Extending Classes With Categories<br />
- Lesson 7 &#8211; Protocols &amp; Key-Value Coding</p>
<h3>Module 4 &#8211; No-BS Cocoa-Touch With iPhone SDK</h3>
<p>- Lesson 1 &#8211; Overview of Cocoa-Touch + Model-View-Controller<br />
- Lesson 2 &#8211; Using Interface Builder (The View)<br />
- Lesson 3 &#8211; Target-Action and the View in Code<br />
- Lesson 4 &#8211; Delegation<br />
- Lesson 5 &#8211; Super-Charging Your View With Interface Builder<br />
- Lesson 6 &#8211; Model &amp; App Architecture</p>
<p><a href="http://mobileappmastery.com/learntoprogram/?utm_source=blog&amp;utm_medium=inpostad&amp;utm_campaign=traffic"><img class="alignright size-medium wp-image-2022" title="DVDCoverSetup" src="http://howtomakeiphoneapps.com/wp-content/uploads/2010/07/DVDCoverSetup-150x130.png" alt="" width="150" height="130" /></a><a href="http://mobileappmastery.com/learntoprogram/?utm_source=blog&amp;utm_medium=inpostad&amp;utm_campaign=traffic">Click here </a>or the box to the right to access to your online workshop now</p>
</div>
<p><a style="display:none" href="http://anyurl.com" rel="tag">CodeProject</a></p>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;title=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&amp;bodytext=Sometimes%20you%20would%20like%20to%20be%20able%20to%20display%20an%20image%20or%20view%20that%20is%20larger%20than%20the%20iPhone%20or%20iPod%20screen.%20%20UIScrollView%20gives%20you%20this%20ability%20plus%20the%20feature%20of%20zooming%20using%20the%20pinch%20gesture.%20%20This%20video%20will%20show%20you%20how%20to%20implement%20this%20i" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;title=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&amp;notes=Sometimes%20you%20would%20like%20to%20be%20able%20to%20display%20an%20image%20or%20view%20that%20is%20larger%20than%20the%20iPhone%20or%20iPod%20screen.%20%20UIScrollView%20gives%20you%20this%20ability%20plus%20the%20feature%20of%20zooming%20using%20the%20pinch%20gesture.%20%20This%20video%20will%20show%20you%20how%20to%20implement%20this%20i" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;t=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;title=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;title=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&amp;annotation=Sometimes%20you%20would%20like%20to%20be%20able%20to%20display%20an%20image%20or%20view%20that%20is%20larger%20than%20the%20iPhone%20or%20iPod%20screen.%20%20UIScrollView%20gives%20you%20this%20ability%20plus%20the%20feature%20of%20zooming%20using%20the%20pinch%20gesture.%20%20This%20video%20will%20show%20you%20how%20to%20implement%20this%20i" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;title=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=Sometimes%20you%20would%20like%20to%20be%20able%20to%20display%20an%20image%20or%20view%20that%20is%20larger%20than%20the%20iPhone%20or%20iPod%20screen.%20%20UIScrollView%20gives%20you%20this%20ability%20plus%20the%20feature%20of%20zooming%20using%20the%20pinch%20gesture.%20%20This%20video%20will%20show%20you%20how%20to%20implement%20this%20i" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;t=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;title=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&amp;body=Sometimes%20you%20would%20like%20to%20be%20able%20to%20display%20an%20image%20or%20view%20that%20is%20larger%20than%20the%20iPhone%20or%20iPod%20screen.%20%20UIScrollView%20gives%20you%20this%20ability%20plus%20the%20feature%20of%20zooming%20using%20the%20pinch%20gesture.%20%20This%20video%20will%20show%20you%20how%20to%20implement%20this%20i" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;title=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F%20How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;t=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&amp;s=Sometimes%20you%20would%20like%20to%20be%20able%20to%20display%20an%20image%20or%20view%20that%20is%20larger%20than%20the%20iPhone%20or%20iPod%20screen.%20%20UIScrollView%20gives%20you%20this%20ability%20plus%20the%20feature%20of%20zooming%20using%20the%20pinch%20gesture.%20%20This%20video%20will%20show%20you%20how%20to%20implement%20this%20i" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F12%2Fhow-to-use-uiscrollview-in-your-iphone-app%2F&amp;t=How%20To%20Use%20UIScrollView%20in%20Your%20iPhone%20App&opener=bm&amp;ei=UTF-8&amp;d=Sometimes%20you%20would%20like%20to%20be%20able%20to%20display%20an%20image%20or%20view%20that%20is%20larger%20than%20the%20iPhone%20or%20iPod%20screen.%20%20UIScrollView%20gives%20you%20this%20ability%20plus%20the%20feature%20of%20zooming%20using%20the%20pinch%20gesture.%20%20This%20video%20will%20show%20you%20how%20to%20implement%20this%20i" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2009/12/how-to-use-uiscrollview-in-your-iphone-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/FirstFrame.jpg&amp;containerwidth=600&amp;containerheight=375&amp;content=http://content.screencast.com/users/AppShop/folders/public/media/8ee80a69-f7a3-496e-9970-1d8cd58c7da4/UseUIScrollView.mp4" length="23753" type="video/mp4" />
		</item>
		<item>
		<title>How To Extend Objective-C Classes With Categories</title>
		<link>http://howtomakeiphoneapps.com/2009/11/how-to-extend-objective-c-classes-with-categories/</link>
		<comments>http://howtomakeiphoneapps.com/2009/11/how-to-extend-objective-c-classes-with-categories/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 18:15:39 +0000</pubDate>
		<dc:creator>mattjdrake</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[iPhone Programming]]></category>
		<category><![CDATA[Category]]></category>
		<category><![CDATA[Cocoa-Touch]]></category>
		<category><![CDATA[Extensibility]]></category>
		<category><![CDATA[how to make iphone apps]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://howtomakeiphoneapps.com/?p=1614</guid>
		<description><![CDATA[Here is how to extend the functionality of existing classes like NSString and NSURL using categories. This is a real clean way to extend and customize objects for your app without creating sub-classes. This makes categories a nice way to get some flexibilty and code reuse. NSString to HTMLString For the demo I am going [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://howtomakeiphoneapps.com/2009/11/how-to-extend-objective-c-classes-with-categories/" title="Permanent link to How To Extend Objective-C Classes With Categories"><img class="post_image alignright remove_bottom_margin frame" src="http://howtomakeiphoneapps.com/wp-content/uploads/2009/11/pileofplussigns.jpg" width="400" height="300" alt="Post image for How To Extend Objective-C Classes With Categories" /></a>
</p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;source=MattjDrake&amp;style=normal&amp;service=bit.ly&amp;hashtags=Category,Cocoa-Touch,Extensibility,how+to+make+iphone+apps,Objective-C" height="61" width="50" /><br />
			</a>
		</div>
<p>Here is how to extend the functionality of existing classes like NSString and NSURL using categories.  This is a real clean way to extend and customize objects for your app without creating sub-classes.  This makes categories a nice way to get some flexibilty and code reuse.</p>
<h3>NSString to HTMLString</h3>
<p>For the demo I am going to create a make-shift HTML editor by extending the NSString classes with methods that enclose text inside of HTML tags.  The app will do this and display the results in an UIWebView.</p>
<p>Here is a quick overview of what the app will do:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="591" height="498" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" /><param name="flashVars" value="thumb=http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/FirstFrame.jpg&amp;containerwidth=591&amp;containerheight=498&amp;content=http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/00000139.mp4" /><param name="allowFullScreen" value="true" /><param name="scale" value="showall" /><param name="allowScriptAccess" value="always" /><param name="base" value="http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/" /><param name="src" value="http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/jingh264player.swf" /><param name="flashvars" value="thumb=http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/FirstFrame.jpg&amp;containerwidth=591&amp;containerheight=498&amp;content=http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/00000139.mp4" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="591" height="498" src="http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/jingh264player.swf" base="http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/" allowscriptaccess="always" scale="showall" allowfullscreen="true" flashvars="thumb=http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/FirstFrame.jpg&amp;containerwidth=591&amp;containerheight=498&amp;content=http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/00000139.mp4" bgcolor="#FFFFFF" quality="high"></embed></object></p>
<h3>Why Use Categories?</h3>
<p>Categories are a clean way of adding behavior that belongs to a class but only in a specific implementation.  You can use a class to add special methods just for one region in your app that does not belong everywhere else.  In the example I am using I want to be able to quickly add HTML tags to certain strings, but this is not something that generally belongs as a function of NSString.</p>
<p>So my app needs HTML support and it logically belongs in NSString for this purpose.  But, I don&#8217;t want all my apps to have this option nor do I want to have to use a special sub-class of NSString throughout this component (because I will never remember to do this later on).  With categories I can define my own behavior for a class and then selectively apply this behavior to classes in my apps when needed.</p>
<h3>Implement HTML Writer With Categories</h3>
<p>Now, let&#8217;s implement the HTML Writer App Using Categories.</p>
<h3>Buttons, Views, TextView and WebViews Oh My!</h3>
<div id="attachment_1612" class="wp-caption alignleft" style="width: 78px">
	<img class="size-medium wp-image-1612 " title="HTML Writer Screen" src="http://howtomakeiphoneapps.com/wp-content/uploads/2009/11/HTMLWriterScreen-78x150.png" alt="HTML Writer Screen" width="78" height="150" />
	<p class="wp-caption-text">HTML Writer Screen</p>
</div>
<p>As a side note I simply used Interface Builder to lay this UI out and hook the components up to the respective IBOutlets and IBActions.  Something I so also is get each UIButton&#8217;s tag property so I can identify it later on in code.  This will be used to identify what tag should be wrapped around the text.</p>
<h3>Extending NSString With HTML</h3>
<p>To start extending NSString all you need to do is to add interface and implementation files and add this code:</p>
<p>Interface File</p>
<pre>	#import &lt;Foundation/Foundation.h&gt;

	@interface NSString (NSString_HTML)

	@end</pre>
<p>Implementation File</p>
<pre>	#import "NSString_HTML.h"

	@implementation NSString (NSString_HTML)

	@end</pre>
<p>This looks a bit like a typical class definition but it is different.  Here after the interface you will see the name of the class that you want to extend (NSString) followed by the name of the category (NSString_HTML).  Other than that this code should look familiar.</p>
<p>BTW: I could have simply included this interface and implementation directly in the file where I want to use the category.  However, since I may want to reuse this code in the future I felt that it makes more sense to keep it in another file.</p>
<h3>Add #define to Represent HTML Tags</h3>
<p>To make things easier on myself I am going to define some integers that will serve as the HTML tags that I am supporting: p, h1, h2, i and u.  I will do this in the interface:</p>
<pre>	#import &lt;Foundation/Foundation.h&gt;

	#define P	0
	#define H1	1
	#define H2	2
	#define U	3
	#define I	4

	@interface NSString (NSString_HTML)

	@end</pre>
<h3>Define Method</h3>
<p>This is where we add the extended functionality to NSString.  I am going to add a method to the category just like I would for a regular class:</p>
<p>Interface</p>
<pre>	#import &lt;Foundation/Foundation.h&gt;

	#define P	0
	#define H1	1
	#define H2	2
	#define U	3
	#define I	4

	@interface NSString (NSString_HTML)

	-(NSString *) stringWithThisTag:(int)tag;

	@end</pre>
<p>Implementation</p>
<pre>	#import "NSString_HTML.h"

	@implementation NSString (NSString_HTML)

	-(NSString *) stringWithThisTag:(int)tag{

	}

	@end</pre>
<p>Now that I have everything in place all I need to do is the actual implementation of the method.  I am simply going to enclose the string based on the integer tag that is passed as a parameter to the method.  I will also use the self keyword to identify the string itself.  Here is an example of the general pattern that I am following:</p>
<pre>	return [NSString stringWithFormat:@"&lt;tag&gt;%@&lt;/tag&gt;",self];</pre>
<p>This is the complete implementation of the method:</p>
<pre>	#import "NSString_HTML.h"

	@implementation NSString (NSString_HTML)

	-(NSString *) stringWithThisTag:(int)tag{
		switch (tag) {
			case P:
				return [NSString stringWithFormat:@"&lt;p&gt;%@&lt;/p&gt;",self];
				break;
			case H1:
				return [NSString stringWithFormat:@"&lt;h1&gt;%@&lt;/h1&gt;",self];
				break;
			case H2:
				return [NSString stringWithFormat:@"&lt;h2&gt;%@&lt;/h2&gt;",self];
				break;
			case U:
				return [NSString stringWithFormat:@"&lt;u&gt;%@&lt;/u&gt;",self];
				break;
			case I:
				return [NSString stringWithFormat:@"&lt;i&gt;%@&lt;/i&gt;",self];
				break;
			default:
				return self;
				break;
		}
	}

	@end</pre>
<h3>Now We Can Use This Method Anywhere!</h3>
<p>Now that we have defined the method to add tag support to NSString we can use it anywhere in our project.  All we need to do is import the category and use the method.  Here is how I did this in my view controller:</p>
<pre>	#import "HTMLWriterViewController.h"
	#import "NSString_HTML.h"

	@implementation HTMLWriterViewController
	@synthesize textView, webView;

	-(IBAction) addTag:(id)sender{
		UIButton *button = sender;
		textView.text = [textView.text stringWithThisTag:button.tag];
	...</pre>
<p>I did omit some of the code here for clarity.  Essentially, at the top I imported NSString_HTML.h which makes the stringWithThisTag method available to me.  Then I use the new function at the end where I pass the tag property of the button that fired the event as a parameter (each UIButton was tagged with an integer that corresponds to the integer that my new function needs to figure out which tag to use).</p>
<h3>See It All Come Together In This Screen Cast</h3>
<p>Check out this video tour of all this code in action as well as some other tweaks that I did with NSURL:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="591" height="498" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" /><param name="flashVars" value="thumb=http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/FirstFrame.jpg&amp;containerwidth=591&amp;containerheight=498&amp;content=http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/00000140.mp4" /><param name="allowFullScreen" value="true" /><param name="scale" value="showall" /><param name="allowScriptAccess" value="always" /><param name="base" value="http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/" /><param name="src" value="http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/jingh264player.swf" /><param name="flashvars" value="thumb=http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/FirstFrame.jpg&amp;containerwidth=591&amp;containerheight=498&amp;content=http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/00000140.mp4" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="591" height="498" src="http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/jingh264player.swf" base="http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/" allowscriptaccess="always" scale="showall" allowfullscreen="true" flashvars="thumb=http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/FirstFrame.jpg&amp;containerwidth=591&amp;containerheight=498&amp;content=http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/00000140.mp4" bgcolor="#FFFFFF" quality="high"></embed></object></p>
<h3>What Behavior Would Be Fun to Add to a Foundation Class?</h3>
<p>Discuss in the comments below!</p>
<p><a style="display:none" rel="tag" href="http://anyurl.com">CodeProject</a></p>



Please share this if you like it!


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;title=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&amp;bodytext=Here%20is%20how%20to%20extend%20the%20functionality%20of%20existing%20classes%20like%20NSString%20and%20NSURL%20using%20categories.%20%20This%20is%20a%20real%20clean%20way%20to%20extend%20and%20customize%20objects%20for%20your%20app%20without%20creating%20sub-classes.%20%20This%20makes%20categories%20a%20nice%20way%20to%20get%20some%20f" title="Digg"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;title=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&amp;notes=Here%20is%20how%20to%20extend%20the%20functionality%20of%20existing%20classes%20like%20NSString%20and%20NSURL%20using%20categories.%20%20This%20is%20a%20real%20clean%20way%20to%20extend%20and%20customize%20objects%20for%20your%20app%20without%20creating%20sub-classes.%20%20This%20makes%20categories%20a%20nice%20way%20to%20get%20some%20f" title="del.icio.us"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;t=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories" title="Facebook"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;title=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories" title="Mixx"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;title=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&amp;annotation=Here%20is%20how%20to%20extend%20the%20functionality%20of%20existing%20classes%20like%20NSString%20and%20NSURL%20using%20categories.%20%20This%20is%20a%20real%20clean%20way%20to%20extend%20and%20customize%20objects%20for%20your%20app%20without%20creating%20sub-classes.%20%20This%20makes%20categories%20a%20nice%20way%20to%20get%20some%20f" title="Google Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&amp;body=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F" title="email"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&amp;link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F" title="FriendFeed"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;title=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&amp;source=How+to+Make+iPhone+Apps+Get+Started+with+Cocoa-Touch+and+iPhone+Programming+today%21&amp;summary=Here%20is%20how%20to%20extend%20the%20functionality%20of%20existing%20classes%20like%20NSString%20and%20NSURL%20using%20categories.%20%20This%20is%20a%20real%20clean%20way%20to%20extend%20and%20customize%20objects%20for%20your%20app%20without%20creating%20sub-classes.%20%20This%20makes%20categories%20a%20nice%20way%20to%20get%20some%20f" title="LinkedIn"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;t=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories" title="MySpace"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;title=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&amp;body=Here%20is%20how%20to%20extend%20the%20functionality%20of%20existing%20classes%20like%20NSString%20and%20NSURL%20using%20categories.%20%20This%20is%20a%20real%20clean%20way%20to%20extend%20and%20customize%20objects%20for%20your%20app%20without%20creating%20sub-classes.%20%20This%20makes%20categories%20a%20nice%20way%20to%20get%20some%20f" title="Ping.fm"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;title=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories" title="StumbleUpon"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F%20How%20To%20Extend%20Objective-C%20Classes%20With%20Categories" title="Suggest to Techmeme via Twitter"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/techmeme.png" title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme via Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F" title="Technorati"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;t=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&amp;s=Here%20is%20how%20to%20extend%20the%20functionality%20of%20existing%20classes%20like%20NSString%20and%20NSURL%20using%20categories.%20%20This%20is%20a%20real%20clean%20way%20to%20extend%20and%20customize%20objects%20for%20your%20app%20without%20creating%20sub-classes.%20%20This%20makes%20categories%20a%20nice%20way%20to%20get%20some%20f" title="Tumblr"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fhowtomakeiphoneapps.com%2F2009%2F11%2Fhow-to-extend-objective-c-classes-with-categories%2F&amp;t=How%20To%20Extend%20Objective-C%20Classes%20With%20Categories&opener=bm&amp;ei=UTF-8&amp;d=Here%20is%20how%20to%20extend%20the%20functionality%20of%20existing%20classes%20like%20NSString%20and%20NSURL%20using%20categories.%20%20This%20is%20a%20real%20clean%20way%20to%20extend%20and%20customize%20objects%20for%20your%20app%20without%20creating%20sub-classes.%20%20This%20makes%20categories%20a%20nice%20way%20to%20get%20some%20f" title="Yahoo! Bookmarks"><img src="http://howtomakeiphoneapps.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://howtomakeiphoneapps.com/2009/11/how-to-extend-objective-c-classes-with-categories/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://content.screencast.com/users/AppShop/folders/Jing/media/60e0adfc-8c09-47be-b939-fe747c853c23/00000139.mp4" length="9993553" type="video/mp4" />
<enclosure url="http://content.screencast.com/users/AppShop/folders/Jing/media/962af8d8-416f-41f7-bbf5-c70fea6047dd/00000140.mp4" length="14189737" type="video/mp4" />
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 6.106 seconds -->
