<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>App Per Month</title>
	
	<link>http://code-ninja.org</link>
	<description>My journey into iOS, Objective-C, and monthly app store releases</description>
	<lastBuildDate>Sun, 19 Feb 2012 17:00:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/code-ninja/GTmQ" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="code-ninja/gtmq" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>iOS Quick Tips: Avoiding SQL injection attacks with parameterized queries in sqlite3</title>
		<link>http://code-ninja.org/blog/2012/02/19/ios-quick-tips-avoiding-sql-injection-attacks-with-parameterized-queries-in-sqlite3/</link>
		<comments>http://code-ninja.org/blog/2012/02/19/ios-quick-tips-avoiding-sql-injection-attacks-with-parameterized-queries-in-sqlite3/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 17:00:57 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[iOS Quick Tips]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=138</guid>
		<description><![CDATA[Since my current app requires a sqlite3 database, I naturally hit up Google for some sqlite3 tutorials. I found plenty of tutorials, but sadly, most of them were poorly written and full of dangerous code. The problem? SQL injection. Most &#8230; <a href="http://code-ninja.org/blog/2012/02/19/ios-quick-tips-avoiding-sql-injection-attacks-with-parameterized-queries-in-sqlite3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since my current app requires a sqlite3 database, I naturally hit up Google for some sqlite3 tutorials. I found plenty of tutorials, but sadly, most of them were poorly written and full of dangerous code. The problem? SQL injection.</p>
<p>Most of the tutorials I saw had code that looked something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> unsafeSqlString <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span>
     <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;UPDATE record SET name=<span style="color: #2400d9;">\&quot;</span>%@<span style="color: #2400d9;">\&quot;</span> WHERE id=%@&quot;</span>, record.name, record.<span style="color: #a61390;">id</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>What&#8217;s the problem here? Good ol&#8217; <a href="http://xkcd.com/327/">Bobby Tables</a>. Depending on what record.name is, your SQL statement may do something that you weren&#8217;t expecting (you <em>didn&#8217;t</em> want to delete all the records in your table? Should&#8217;ve thought of that before writing such unsafe code!).</p>
<p>The correct way to do this is with parameterized queries. In sqlite3, you use parameterized queries by replacing your values with ?&#8217;s in your SQL statement. So the above unsafe SQL statement becomes this:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> safeSqlString <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;UPDATE record SET name=? where id=?&quot;</span>;</pre></div></div>

<p>You then prepare a SQL statement with your query:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">sqlite3_stmt<span style="color: #002200;">*</span> statement;
<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>sqlite3_prepare<span style="color: #002200;">&#40;</span>database, <span style="color: #002200;">&#91;</span>safeSqlString UTF8String<span style="color: #002200;">&#93;</span>, <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>, <span style="color: #002200;">&amp;</span>statement, <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">!=</span> SQLITE_OK<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Add your error handling code here</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Finally, you bind all of your parameters to set the actual values that will be used when your query is executed:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>sqlite3_bind_text<span style="color: #002200;">&#40;</span>statement, <span style="color: #2400d9;">1</span>, <span style="color: #002200;">&#91;</span>record.name UTF8String<span style="color: #002200;">&#93;</span>, <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>, SQLITE_TRANSIENT<span style="color: #002200;">&#41;</span> <span style="color: #002200;">!=</span> SQLITE_OK<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Add your error handling code here</span>
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>sqlite3_bind_int<span style="color: #002200;">&#40;</span>statement, <span style="color: #2400d9;">2</span>, record.key <span style="color: #002200;">!=</span> SQLITE_OK<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Add your error handling code here</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>For more details on all the different sqlite3_bind functions, see the <a href="http://www.sqlite.org/c3ref/bind_blob.html">SQLite documentation</a>.</p>
<p>Finally, you execute your safe, injection-free SQL statement:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>sqlite3_step<span style="color: #002200;">&#40;</span>statement<span style="color: #002200;">&#41;</span> <span style="color: #002200;">!=</span> SQLITE_DONE<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Add your error handling code here</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Sure, avoiding SQL injection attacks in a small iOS app is probably less of an issue than avoiding them in a mission-critical website, but that&#8217;s no excuse to do it wrong. And here&#8217;s another, even more obvious reason to do it right: If any of your fields have a &#8221; in them, your unsafe SQL statement will fail. The parameterized statement handles quotes correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/02/19/ios-quick-tips-avoiding-sql-injection-attacks-with-parameterized-queries-in-sqlite3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postmortem: BBQ Menu</title>
		<link>http://code-ninja.org/blog/2012/02/16/postmortem-bbq-menu/</link>
		<comments>http://code-ninja.org/blog/2012/02/16/postmortem-bbq-menu/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 01:33:32 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[Postmortems]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=123</guid>
		<description><![CDATA[Now that January&#8217;s app &#8211; BBQ Menu - is available on the App Store, I thought I would do a quick postmortem for it. Postmortems will likely become a regular feature of this blog, and I suspect that they will &#8230; <a href="http://code-ninja.org/blog/2012/02/16/postmortem-bbq-menu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Now that January&#8217;s app &#8211; <a href="http://code-ninja.org/apps/bbq-menu/">BBQ Menu </a>- is available on the App Store, I thought I would do a quick postmortem for it. Postmortems will likely become a regular feature of this blog, and I suspect that they will normally be a little bigger than this one.</p>
<p>Development Time: ~15 Hours. This is a pretty rough estimate as I wasn&#8217;t keeping track of time. I have since started using Thyme to track my hours.</p>
<p>Review Time (time spent in the iOS app submission queue): 7 days</p>
<p>New technologies used: Everything! As this was my first app, everything was new, from UITableViews to Xcode to distribution and deployment.</p>
<p>Challenges: Aside from getting acclimated to an entirely new set of development tools, the hardest part was figuring out where to draw a line in terms of features. It&#8217;s a delicate balance between the desire for more features, and the desire for a simple, easy to use application.</p>
<p>Future plans: There are a number of bug fixes coming in the immediate future, and possibly some new features and a prettier UI shortly thereafter. If you have any feedback regarding BBQ Menu, please drop me a line!</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/02/16/postmortem-bbq-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS Quick Tip – UITableView with static cells not showing up</title>
		<link>http://code-ninja.org/blog/2012/02/11/ios-quick-tip-uitableview-with-static-cells-not-showing-up/</link>
		<comments>http://code-ninja.org/blog/2012/02/11/ios-quick-tip-uitableview-with-static-cells-not-showing-up/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 02:56:20 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[iOS Quick Tips]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=115</guid>
		<description><![CDATA[If you&#8217;ve ever tried to create a UITableView with static cells, you may have run across some difficulties in getting your cells to actually show up. The trick is to remove the following row, cell, and section methods from your &#8230; <a href="http://code-ninja.org/blog/2012/02/11/ios-quick-tip-uitableview-with-static-cells-not-showing-up/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever tried to create a UITableView with static cells, you may have run across some difficulties in getting your cells to actually show up.</p>
<p>The trick is to remove the following row, cell, and section methods from your UITableViewController subclass. They are automatically added by Xcode, but if you are using static cells, you <em>don&#8217;t</em> want them in your class.</p>
<p>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView</p>
<p>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section</p>
<p>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</p>
<p>Once you have removed these methods, your cells will show up correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/02/11/ios-quick-tip-uitableview-with-static-cells-not-showing-up/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>January’s Goal – Complete</title>
		<link>http://code-ninja.org/blog/2012/02/04/januarys-goal-complete/</link>
		<comments>http://code-ninja.org/blog/2012/02/04/januarys-goal-complete/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 17:43:46 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=112</guid>
		<description><![CDATA[Sort of. I submitted January&#8217;s app to the app store on the 30th, but it&#8217;s still waiting for review. So although it&#8217;s not technically in the app store yet, I consider this a pretty successful month. And I&#8217;m already hard &#8230; <a href="http://code-ninja.org/blog/2012/02/04/januarys-goal-complete/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sort of.</p>
<p>I submitted January&#8217;s app to the app store on the 30th, but it&#8217;s still waiting for review. So although it&#8217;s not technically in the app store yet, I consider this a pretty successful month. And I&#8217;m already hard at work on February&#8217;s app &#8211; this time using <a href="http://joaomoreno.github.com/thyme/">Thyme</a> to keep track of exactly how long it takes to build.</p>
<p>I&#8217;ll put up more info on each of the apps as they are released</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/02/04/januarys-goal-complete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS Pain Points: Renaming folders in Xcode</title>
		<link>http://code-ninja.org/blog/2012/01/31/ios-pain-points-renaming-folders-in-xcode/</link>
		<comments>http://code-ninja.org/blog/2012/01/31/ios-pain-points-renaming-folders-in-xcode/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 05:23:51 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[iOS Pain Points]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=100</guid>
		<description><![CDATA[Xcode, in all its mind-bogglingly incomprehensible wisdom, makes the simple act of renaming a folder a chore. If you&#8217;ve ever used any IDE ever released on any other platform in the history of computing, you would think it would be &#8230; <a href="http://code-ninja.org/blog/2012/01/31/ios-pain-points-renaming-folders-in-xcode/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Xcode, in all its mind-bogglingly incomprehensible wisdom, makes the simple act of renaming a folder a chore. If you&#8217;ve ever used any IDE ever released on any other platform in the history of computing, you would think it would be as simple as right-clicking (er, command-clicking) on the folder and selecting &#8216;Rename&#8217;. Sadly, no. There&#8217;s no rename option. But wait &#8211; there&#8217;s a &#8216;Group Name&#8217; option in the File Inspector. Just change that and&#8230; nope. That just changes the name as it appears in Xcode, not the name of the actual folder on disk. What you actually appear to have to do is rename the folder in Finder, then click on the little folder icon in the File Inspector and point the group to the new folder.</p>
<p>Oh, and don&#8217;t even think about <a href="http://stackoverflow.com/questions/8262613/renaming-xcode-4-project-and-the-source-folder">renaming your project.</a> That would just be stupid.</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/01/31/ios-pain-points-renaming-folders-in-xcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS Pain Points: $99 per year developer program</title>
		<link>http://code-ninja.org/blog/2012/01/23/ios-pain-points-99-per-year-developer-program/</link>
		<comments>http://code-ninja.org/blog/2012/01/23/ios-pain-points-99-per-year-developer-program/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 06:02:13 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[iOS Pain Points]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=95</guid>
		<description><![CDATA[In order to distribute your work on the app store, or test your work on your device, you need to sign up for the iOS developer program at a cost of $99 per year. What purpose does this fee serve, &#8230; <a href="http://code-ninja.org/blog/2012/01/23/ios-pain-points-99-per-year-developer-program/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In order to distribute your work on the app store, or test your work on your device, you need to sign up for the <a href="http://developer.apple.com/programs/ios/">iOS developer program</a> at a cost of $99 per year.</p>
<p>What purpose does this fee serve, aside from turning away potential developers?</p>
<p>It&#8217;s certainly not making Apple rich. According to Apple, there are <a href="http://www.apple.com/iphone/built-in-apps/app-store.html">over 500,000 apps</a> on the app store. If we make the tenuous assumption that there&#8217;s a 1 to 1 ratio of apps to app developers, we can guess that there are around 500,000 registered iOS developers, who altogether make Apple a tidy sum of $49.5 million dollars per year. Sounds great, right? Well, not when you consider that took in <a href="http://www.apple.com/pr/library/2011/10/18Apple-Reports-Fourth-Quarter-Results.html"><em>$28 billion</em> in revenue in the last quarter alone</a>. That 49.5 million dollars in annual developer program fees is approximately 0.017 % of Apple&#8217;s quarterly revenue. Less than a drop in the bucket.</p>
<p>No, the real reason, as I see it, is to intentionally raise the bar to attract only the developers who are serious about the platform. Were there no annual fee, the app store would likely be (even more) deluged with lower quality apps, and the approvals team would be even more swamped than they already are. This is certainly a valid point, but it hurts small developers, as even the simplest apps now have to sell approximately 142 copies per year just to cover the developer program fees (and that&#8217;s not even considering the other fees associated with iOS development). As a newcomer to iOS development, this is a somewhat scary number.</p>
<p>Since the motivation for the annual fee is quality, not direct financial gain, I have an idea to ease this pain: refund some or all of the fee for each app that is successfully submitted to the App store. By doing this, Apple would still create its desired barrier to entry, but it would be less of a burden on small-time developers. And as the money would not be refunded until an app successfully passed the submission process, developers would have just as much incentive &#8211; if not more &#8211; to release high-quality apps.</p>
<p>Of course, none of this matters, because Apple would never do such a thing. But I can dream.</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/01/23/ios-pain-points-99-per-year-developer-program/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iOS Cool Stuff: Storyboards</title>
		<link>http://code-ninja.org/blog/2012/01/19/ios-cool-stuff-storyboards/</link>
		<comments>http://code-ninja.org/blog/2012/01/19/ios-cool-stuff-storyboards/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 04:44:04 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[iOS Cool Stuff]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=39</guid>
		<description><![CDATA[Storyboards are one of the coolest features of Xcode and iOS development. New to Xcode 4.2, they not only give you a visual overview of all the screens in your application, but they show you the transitions &#8211; or segues &#8230; <a href="http://code-ninja.org/blog/2012/01/19/ios-cool-stuff-storyboards/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Storyboards are one of the coolest features of Xcode and iOS development. New to Xcode 4.2, they not only give you a visual overview of all the screens in your application, but they show you the transitions &#8211; or segues &#8211; between the screens.</p>
<p>This is a few steps above and beyond the likes of what Visual Studio can do. Instead of seeing a single control or a single window at a time, you can see all of them, plus the way they relate to each other.</p>
<p><a href="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-18-at-8.05.34-PM.png"><img class="aligncenter size-full wp-image-89" title="Screen Shot 2012-01-18 at 8.05.34 PM" src="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-18-at-8.05.34-PM.png" alt="" width="503" height="529" /></a></p>
<p>Some of the features of storyboards are not particularly discoverable, though, such as the Ctrl-clicking and dragging to create a segue (or an outlet, but I believe that&#8217;s just part of Interface Builder that&#8217;s been there for a while, not a feature specific to storyboards). There are also some fairly unintuitive behaviors with regards to zooming and selecting. It appears that there are only four zoom levels &#8211; you can&#8217;t zoom in or zoom out arbitrarily. And selection works differently at the different zoom levels. For example, if you aren&#8217;t zoomed in all the way, you can&#8217;t select individual controls; you can only select entire views. But if you click on a control in the document outline, you are suddenly zoomed in to it. Not deal breakers, of course; just things that might initially surprise you.</p>
<p><a href="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-18-at-8.41.01-PM.png"><img class="aligncenter size-full wp-image-90" title="Screen Shot 2012-01-18 at 8.41.01 PM" src="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-18-at-8.41.01-PM.png" alt="" width="335" height="318" /></a></p>
<p>Minor quibbles aside, storyboards are a terrific step forward in the realm of visual designers, and one that I would love to see in Visual Studio.</p>
<p>By the way, if you&#8217;re looking for a great storyboard tutorial, check out <a href="http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1">Ray Wenderlich&#8217;s Beginning Storyboards Tutorial</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/01/19/ios-cool-stuff-storyboards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS Pain Points: Multiselect of UITableViewCell children in Interface Builder</title>
		<link>http://code-ninja.org/blog/2012/01/15/ios-pain-points-multiselect-in-interface-builder/</link>
		<comments>http://code-ninja.org/blog/2012/01/15/ios-pain-points-multiselect-in-interface-builder/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 20:16:26 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[iOS Pain Points]]></category>
		<category><![CDATA[iOS Quick Tips]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=83</guid>
		<description><![CDATA[This is a quick one. Multiselect in a UI designer is a pretty standard operation. If I want to change a property on a number of controls at once, I should be able to simply ctrl-click them (or command-click, or &#8230; <a href="http://code-ninja.org/blog/2012/01/15/ios-pain-points-multiselect-in-interface-builder/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a quick one.</p>
<p>Multiselect in a UI designer is a pretty standard operation. If I want to change a property on a number of controls at once, I should be able to simply ctrl-click them (or command-click, or option-click, and so on) to select them all, and change the property.</p>
<p>Unfortunately Interface Builder doesn&#8217;t seem to support multiple selection on controls in different UITableViewCells. Attempting to do so always results in the first control being deselected.</p>
<p>However, there is a workaround, which is why this entry is really half &#8216;iOS Pain Points&#8217;, and half &#8216;iOS Quick Tips&#8217;. It turns out you can multiselect across table cels by command-clicking in the Document Outline window on the left.</p>
<p><a href="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-15-at-12.13.51-PM.png"><img class="aligncenter size-full wp-image-84" title="Screen Shot 2012-01-15 at 12.13.51 PM" src="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-15-at-12.13.51-PM.png" alt="" width="270" height="288" /></a>Not entirely intuitive, but it does the trick!</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/01/15/ios-pain-points-multiselect-in-interface-builder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS Quick Tip: Setting the default view controller on a storyboard</title>
		<link>http://code-ninja.org/blog/2012/01/13/ios-quick-tip-setting-the-default-view-controller-on-a-storyboard/</link>
		<comments>http://code-ninja.org/blog/2012/01/13/ios-quick-tip-setting-the-default-view-controller-on-a-storyboard/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 04:29:26 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[iOS Quick Tips]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=76</guid>
		<description><![CDATA[Figuring out how to set the default view controller on a storyboard is surprisingly unintuitive, especially as someone new to iOS development. It seemed logical to me that it would be some sort of setting on the storyboard itself. However, &#8230; <a href="http://code-ninja.org/blog/2012/01/13/ios-quick-tip-setting-the-default-view-controller-on-a-storyboard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Figuring out how to set the default view controller on a storyboard is surprisingly unintuitive, especially as someone new to iOS development. It seemed logical to me that it would be some sort of setting on the storyboard itself. However, it&#8217;s actually the exact opposite &#8211; it&#8217;s a setting on the <em>view controller</em>.</p>
<p>This is somewhat bizzare as it means setting a property on one view controller can affect other view controllers, but nevertheless, it&#8217;s quite simple. Here&#8217;s what you need to do:</p>
<ul>
<li>Open your storyboard</li>
<li>Click on the view controller corresponding to the view that you want to be the default view</li>
<li>Open the Attributes Inspector</li>
<li>Check the<strong> Is Initial View Controller</strong> check box in the View Controller section</li>
</ul>
<p style="text-align: center;"><img class="size-full wp-image-80 aligncenter" style="color: #333333; font-style: normal; line-height: 24px; border-style: initial; border-color: initial;" title="Screen Shot 2012-01-12 at 8.24.45 PM" src="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-12-at-8.24.45-PM.png" alt="" width="265" height="350" /></p>
<p>Voila! Your view controller is now the default view controller for this storyboard.</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/01/13/ios-quick-tip-setting-the-default-view-controller-on-a-storyboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS Quick Tip: Filtering a UITableView with a search bar</title>
		<link>http://code-ninja.org/blog/2012/01/08/ios-quick-tip-filtering-a-uitableview-with-a-search-bar/</link>
		<comments>http://code-ninja.org/blog/2012/01/08/ios-quick-tip-filtering-a-uitableview-with-a-search-bar/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 08:03:25 +0000</pubDate>
		<dc:creator>Marty Dill</dc:creator>
				<category><![CDATA[iOS Quick Tips]]></category>

		<guid isPermaLink="false">http://code-ninja.org/?p=61</guid>
		<description><![CDATA[Step 1: Add a UISearchBar to your UITableView and create an outlet for it. Step 2: Add properties for the array of all the table data, and the array of filtered table data. @property &#40;strong, nonatomic&#41; NSMutableArray* allTableData; @property &#40;strong, &#8230; <a href="http://code-ninja.org/blog/2012/01/08/ios-quick-tip-filtering-a-uitableview-with-a-search-bar/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Step 1: Add a UISearchBar to your UITableView and create an outlet for it.<br />
<a href="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-07-at-7.29.12-PM.png"><img src="http://code-ninja.org/wp-content/uploads/2012/01/Screen-Shot-2012-01-07-at-7.29.12-PM.png" alt="" title="Screen Shot 2012-01-07 at 7.29.12 PM" width="351" height="330" class="alignnone size-full wp-image-69" /></a></p>
<p>Step 2: Add properties for the array of all the table data, and the array of filtered table data.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>strong, nonatomic<span style="color: #002200;">&#41;</span> <span style="color: #400080;">NSMutableArray</span><span style="color: #002200;">*</span> allTableData;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>strong, nonatomic<span style="color: #002200;">&#41;</span> <span style="color: #400080;">NSMutableArray</span><span style="color: #002200;">*</span> filteredTableData;</pre></div></div>

<p>Step 3: Assign your search bar&#8217;s delegate to your controller class.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad
<span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// ...Do initialization stuff here...</span>
&nbsp;
    searchBar.delegate <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>self;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Step 4: Implement the searchBar:textDidChange: method from the UISearchBarDelegate protocol. This will let you filter your list as you type. If you want to filter when the search button is clicked, use the searchBarSearchButtonClicked: method instead.</p>
<p>In this example, we are searching through a list of foods with names and descriptions to see if the match the search text. If they do, we add them to our NSMutableArray containing our filtered foods. We also set a flag that indicates whether or not we are currently filtering the list.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>searchBar<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UISearchBar<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>searchBar textDidChange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>text
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>text.length <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        isFiltered <span style="color: #002200;">=</span> FALSE;
    <span style="color: #002200;">&#125;</span>
    <span style="color: #a61390;">else</span>
    <span style="color: #002200;">&#123;</span>
        isFiltered <span style="color: #002200;">=</span> <span style="color: #a61390;">true</span>;
        filteredTableData <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableArray</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
        <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>Food<span style="color: #002200;">*</span> food <span style="color: #a61390;">in</span> allTableData<span style="color: #002200;">&#41;</span>
        <span style="color: #002200;">&#123;</span>
            <span style="color: #a61390;">NSRange</span> nameRange <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>food.name rangeOfString<span style="color: #002200;">:</span>text options<span style="color: #002200;">:</span>NSCaseInsensitiveSearch<span style="color: #002200;">&#93;</span>;
            <span style="color: #a61390;">NSRange</span> descriptionRange <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>food.description rangeOfString<span style="color: #002200;">:</span>text options<span style="color: #002200;">:</span>NSCaseInsensitiveSearch<span style="color: #002200;">&#93;</span>;
            <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>nameRange.location <span style="color: #002200;">!=</span> NSNotFound || descriptionRange.location <span style="color: #002200;">!=</span> NSNotFound<span style="color: #002200;">&#41;</span>
            <span style="color: #002200;">&#123;</span>
                <span style="color: #002200;">&#91;</span>filteredTableData addObject<span style="color: #002200;">:</span>food<span style="color: #002200;">&#93;</span>;
            <span style="color: #002200;">&#125;</span>
        <span style="color: #002200;">&#125;</span>
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #002200;">&#91;</span>self.tableView reloadData<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Step 5: Modify our other UITableViewController methods to make them aware of the isFiltering flag, and to use the correct list depending on whether or not we are filtering.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView numberOfRowsInSection<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>section
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">int</span> rowCount;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self.isFiltered<span style="color: #002200;">&#41;</span>
        rowCount <span style="color: #002200;">=</span> filteredTableData.count;
    <span style="color: #a61390;">else</span>
        rowCount <span style="color: #002200;">=</span> allTableData.count;
&nbsp;
    <span style="color: #a61390;">return</span> rowCount;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSIndexPath</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">static</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>CellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;
&nbsp;
    UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span>
        cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> initWithStyle<span style="color: #002200;">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span>;
&nbsp;
    Food<span style="color: #002200;">*</span> food;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>isFiltered<span style="color: #002200;">&#41;</span>
        food <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>filteredTableData objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">else</span>
        food <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>allTableData objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// ... Set up the cell here...;</span>
&nbsp;
    <span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Voila! You now have a UITableView that can be filtered using a UISearchBar.</p>
]]></content:encoded>
			<wfw:commentRss>http://code-ninja.org/blog/2012/01/08/ios-quick-tip-filtering-a-uitableview-with-a-search-bar/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

