<?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>Rune&#039;s Blog &#187; Xcode</title>
	<atom:link href="http://runmad.com/blog/tag/xcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://runmad.com/blog</link>
	<description>A blog about code, graphics, UI, marketing and whatever else interests me. Follow me on Twitter: @runmad</description>
	<lastBuildDate>Sat, 28 Jan 2012 14:08:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Random tips</title>
		<link>http://runmad.com/blog/2010/11/random-tips/</link>
		<comments>http://runmad.com/blog/2010/11/random-tips/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 19:17:57 +0000</pubDate>
		<dc:creator>Rune Madsen</dc:creator>
				<category><![CDATA[#idevblogaday]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[User Interface]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[shadowcolor]]></category>
		<category><![CDATA[shadowOffset]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[uilabel]]></category>
		<category><![CDATA[uinavigationcontroller]]></category>
		<category><![CDATA[uitoolbar]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://runmad.com/blog/?p=217</guid>
		<description><![CDATA[I was expecting this blog post to be about something completely different, but I&#8217;m still out of the country and have come down with a bad cold, so it&#8217;ll be a bit of a short and simple. I&#8217;ve decided just to a few coding tips, I have come across and though might be useful for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://runmad.com/blog/wp-content/uploads/2010/11/randomtipsheader.png"><img class="aligncenter size-full wp-image-262" title="randomtipsheader" src="http://runmad.com/blog/wp-content/uploads/2010/11/randomtipsheader.png" alt="" width="616" height="250" /></a></p>
<p>I was expecting this blog post to be about something completely different, but I&#8217;m still out of the country and have come down with a bad cold, so it&#8217;ll be a bit of a short and simple.</p>
<p>I&#8217;ve decided just to a few coding tips, I have come across and though might be useful for other devs, especially if you haven&#8217;t worked much with UIKit before in your development, or perhaps just these areas below. (At the bottom of this post is an Xcode project file which includes examples of the tips below).</p>
<p><strong>Tip #1: Check for URL scheme and open correct app from your own<br />
</strong>You&#8217;ll probably run into having to link to another app, for example your company&#8217;s Twitter account. Instead of just linking to the Twitter website, you can do a quick check in code and open the Twitter app instead. You can also do it with other Twitter client apps as well, however, not all have URL schemes setup (that I could find), and most users will probably be using the official one anyway. Regardless, the code is good to do the same check for other apps, or if Twitter.app doesn&#8217;t exists on the user&#8217;s device, you can try another Twitter client app, or use a UIAlertView to ask the user what else they&#8217;d like to use (depending on which ones are possible to open using the URL scheme).</p>
<p>Basically, all you have to do is ask whether UIApplication responds to the URL:</p>
<pre class="brush: objc; title: ; notranslate">BOOL twitter = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@&quot;twitter://user?screen_name=runmad&quot;]];
if (!twitter) {
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@&quot;http://www.twitter.com/runmad&quot;]];
} else {
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@&quot;twitter://user?screen_name=runmad&quot;]];
}</pre>
<p>List of URL Schemes: <a href="http://wiki.akosma.com/IPhone_URL_Schemes" target="_blank">http://wiki.akosma.com/IPhone_URL_Schemes</a> <strong> </strong></p>
<p><strong>Tip #2: Getting a free UINavigationController in your UIViewController<br />
<span style="font-weight: normal;">I have seen some apps that use a UIToolbar as a navigation bar, and this just doesn&#8217;t work. If you compare the two, they&#8217;re actually a bit different, and this really shows when put in the wrong place.</span></strong></p>
<p><strong><span style="font-weight: normal;">If you&#8217;ve got a UIViewController, turning it into a UINavigationController is really easy:</span></strong></p>
<pre class="brush: objc; title: ; notranslate">RootViewController *rootViewController = [[RootViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[self.navigationController presentModalViewController:navigationController animated:YES];
[rootViewController release];
[navigationController release];</pre>
<p><strong>Tip #3: Getting a free UIToolbar in your UINavigationController<br />
<span style="font-weight: normal;">This one I only just recently found out (thanks to <a href="http://twitter.com/auibrian" target="_blank">@auibrian</a>)</span></strong>. UINavigationController actually comes with a UIToolbar. It&#8217;s property is set to hidden:YES by default, so all you have to do is override this property when you load the view.</p>
<pre class="brush: objc; title: ; notranslate">[self.navigationController setToolbarHidden:NO];</pre>
<p>Note: I have seen some weird behaviour when pushing view controllers onto the screen (buttons not getting a pushing animation, just appearing in the toolbar in place). Also, you will need to hide the toolbar if you&#8217;re popping or pushing to a view controller that you do not want to show the toolbar (because with pushing you&#8217;re reusing the same navigation controller). In my opinion it&#8217;s not a very good way, I wish the view controllers were more separate for this.</p>
<p><strong>Tip #4: Use shadowColor and shadowOffset appropriately when faking text indention<span style="font-weight: normal;"><br />
One thing that bugs me are improper use of a UILabel&#8217;s shadowColor and shadowOffset. When using these, one has to pay attention to the colour of the background as well as the text colour. In the below example (when we&#8217;re going for the look where text looks carved into the display, used by Apple across the entire UI), we&#8217;ll see that when using darker text, use a lighter colour for the shadow and a positive value for the offset. </span></strong></p>
<p><strong><span style="font-weight: normal;">When displaying lighter coloured text, use a darker shadow colour and a negative value for the offset, which in both cases create the proper indented or &#8220;carved&#8221; effect.</span></strong></p>
<p><strong><strong><span style="font-weight: normal;"><a href="http://runmad.com/blog/wp-content/uploads/2010/11/properfaketextindenting.png"><img class="aligncenter size-full wp-image-257" title="properfaketextindenting" src="http://runmad.com/blog/wp-content/uploads/2010/11/properfaketextindenting.png" alt="" width="300" height="150" /></a></span></strong></strong></p>
<p><strong><strong><span style="font-weight: normal;">Using the wrong combination doesn&#8217;t create this effect and makes the text appear raised from the rest of your UI, which is most likely not what you should be going for in most cases ;)</span></strong></strong></p>
<p>I&#8217;ve made a small Xcode project you can download <a href="http://runmad.com/blog/wp-content/uploads/2010/11/TipsFromRune.zip">here</a>, which has the code examples from tips 1, 2 and 3 and I suppose #4 as well, since navigationItem.title is using text indention.</p>
<p>Again, apologies for a bit of a short and simple post due to being under the weather and traveling.</p>
]]></content:encoded>
			<wfw:commentRss>http://runmad.com/blog/2010/11/random-tips/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quick guide to updating your app&#8217;s UI for iPhone 4</title>
		<link>http://runmad.com/blog/2010/06/quick-guide-to-updating-your-apps-ui-for-iphone-4/</link>
		<comments>http://runmad.com/blog/2010/06/quick-guide-to-updating-your-apps-ui-for-iphone-4/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 02:54:26 +0000</pubDate>
		<dc:creator>Rune Madsen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone 4]]></category>
		<category><![CDATA[User Interface]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[experience]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[retina]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://runmad.com/blog/?p=198</guid>
		<description><![CDATA[iPhone 4 will make your UI look stunning. Everything in UIKit has been scaled up already so it will require only a bit of work on your end to make the rest of your app look amazing on iPhone 4. If you only code and don&#8217;t touch Photoshop, you&#8217;re in luck. However, if you&#8217;re a UI [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://runmad.com/blog/wp-content/uploads/2010/06/iPhone4ResolutionScreenshot.png"><img class="aligncenter size-full wp-image-207" title="iPhone4ResolutionScreenshot" src="http://runmad.com/blog/wp-content/uploads/2010/06/iPhone4ResolutionScreenshot.png" alt="" width="616" height="260" /></a></p>
<p>iPhone 4 will make your UI look stunning. Everything in UIKit has been scaled up already so it will require only a bit of work on your end to make the rest of your app look amazing on iPhone 4. If you only code and don&#8217;t touch Photoshop, you&#8217;re in luck. However, if you&#8217;re a UI designer or have the skills to do your own UI, hopefully you did your original artwork in a nice high resolution &#8211; if not, you have a bit of work cut out for you with updating all the UI elements to 2x the resolution.</p>
<p>Updating your app&#8217;s UI to be compatible with iPhone 4&#8242;s <a href="http://www.apple.com/iphone/features/retina-display.html" target="_blank">Retina Display</a> is amazingly simple. Since the scale works in points, not pixels, you will have to do very little work on the layout itself. Apple Engineers have made it really simple to use new graphics for all your UI on iPhone 4, at the same time as being compatible (and not using 2x memory) on older, lower resolution, lower memory devices.</p>
<p>All you have to do is add the same image file at 2x the pixels to your app&#8217;s resources and name it the same it&#8217;s lower resolutions sibling with the following suffix: &#8220;@2x&#8221;.</p>
<p>For example, in your Resources folder, you will now need to have two image files, one for older devices called <em>myImage.png and </em>one for iPhone 4 called <em>myImage@2x.png, </em>which is twice the resolution.</p>
<p>This way, when you call <em>[UIImage imageNamed:@"myImage.png"]</em>; (or <em>contentsOfFile:)</em> iPhone 4 will <strong>automatically</strong> grab the filename with a @2x suffix, and lower resolution images will grab the lower resolution copy. You don&#8217;t have to check for the device loading the image and write any additional code to grab the correct image. Genius!</p>
<p>If you have seen an iPhone app on the iPad in 2x scale, that&#8217;s pretty much how your app is going to look on the iPhone 4. Perhaps not so drastic, but there will be a noticeable difference from app not optimized for iPhone 4 and &#8220;Retina Apps&#8221; as Apple calls them.</p>
<p><strong>Thoughts on @2x on iPad&#8230;</strong><br />
I didn&#8217;t hear anything at WWDC regarding this, but my thought is that they&#8217;ll integrate this into the iPad for the next major OS release. Basically, it will be able to do the same and grab the higher resolution image appropriately for iPhone apps running at 2x scale.</p>
<p>Happy Photoshopping to UI designers and happy relaxing programmers!</p>
<table width="100%">
<tbody>
<tr>
<td><span style="font-weight: bold; color: #000000;">UPDATE JULY 7, 2010:</span></td>
</tr>
</tbody>
</table>
<p>I have discovered a bug in Apple&#8217;s code that deals with grabbing the correct image on iPhone 4. If you are using imageWithContentsOfFile: the code will in fact not automatically grab the @2x if running on iPhone 4. I have submitted a bug report to Apple, and they&#8217;ve informed me they are now aware of the issue and the Engineers are currently working to fix the bug. So for now, stick with imageNamed: for all your images.</p>
]]></content:encoded>
			<wfw:commentRss>http://runmad.com/blog/2010/06/quick-guide-to-updating-your-apps-ui-for-iphone-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Debugging Executables for Push Notifications</title>
		<link>http://runmad.com/blog/2010/06/debugging-executables-for-push-notifcations/</link>
		<comments>http://runmad.com/blog/2010/06/debugging-executables-for-push-notifcations/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 15:33:09 +0000</pubDate>
		<dc:creator>Rune Madsen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[executable]]></category>
		<category><![CDATA[push notifications]]></category>

		<guid isPermaLink="false">http://runmad.com/blog/?p=193</guid>
		<description><![CDATA[I am implementing Push Notifications in one of my apps. Doing so may be a bit tricky in terms of debugging since you cannot actually debug incoming Push Notifications appropriately while the app is running, so I wanted to share this tip. Also, I am writing this post on my iPad on an airplane, so [...]]]></description>
			<content:encoded><![CDATA[<p>I am implementing Push Notifications in one of my apps. Doing so may be a bit tricky in terms of debugging since you cannot actually debug incoming Push Notifications appropriately while the app is running, so I wanted to share this tip. Also, I am writing this post on my iPad on an airplane, so pretty excited about that :)</p>
<p>Xcode allows you to debug applications that are running locally on your device. You can even set breakpoints in your code and print out any information you may need from the console in order to debug your app and fix whatever issue you&#8217;re experiencing, should you not be able to fix it via &#8220;live&#8221; debugging.</p>
<p>This feature is especially useful if you&#8217;re doing Push Notifications (a great way to easily communicate information to your user with their permission, such as notifications, reminders, marketing (be careful with this one), etc.).</p>
<p>With Push Notifications, your app receives data from Apple Push Notification servers in a dictionary in the UIApplication delegate <em>application:didFinishLaunchingWithOptions:</em> that you&#8217;ll need to parse and do in your app whatever is appropriate for the implementation you&#8217;ve chosen (launching with specific views in front, etc.). Since your app cannot be running while receiving Push Notifications (it actually does receive notifications while running, but you&#8217;re required to deal with that through another delegate method), you&#8217;ll need to use the &#8220;debug executables&#8221; with &#8220;Wait for next launch/push notifications&#8221; ticked. Once you run the debugger and launch your app (for example directly via a Push Notifications UIAlertView) you can set breakpoints anywhere in your code and use the console to print out (po) any objects you may wish to inspect.</p>
<p>As your app launches immediately when you debug, it&#8217;s a problem if you&#8217;re debugging Push Notification (which, by the way, does not work in Simulator). So here&#8217;s the hidden treasure in Xcode: In the Groups &amp; Folder pane, find Executables, expand and select your app executable. Hit command+option+i to &#8220;Get Info&#8221; and select the Debugging tab. From here, tick &#8220;Wait for next launch/push notification&#8221;.</p>
<p><img class="aligncenter size-full wp-image-195" title="Executable Info" src="http://runmad.com/blog/wp-content/uploads/2010/06/ExecutableInfo.png" alt="" width="470" height="423" /></p>
<p>Now, when you Run &amp; Debug your app it will not launch, but instead wait until you tap the app icon to launch it or the app is launched via a Push Notification UIAlertView (this of course requires you have not set the &#8220;action-loc-key&#8221; to null in your Push Notification JSON dictionary).</p>
<p><a href="http://runmad.com/blog/wp-content/uploads/2010/06/WaitingForLaunch.png"><img class="aligncenter size-full wp-image-196" title="Waiting For Launch" src="http://runmad.com/blog/wp-content/uploads/2010/06/WaitingForLaunch.png" alt="" width="543" height="193" /></a></p>
<p>Once your app launches via a Push Notification, it will stop at the breakpoint you set and you can now print out any information you need to debug your app, such as the NSDictionary your app receives, whether the appropriate view will be displayed and any other issue you may have.</p>
]]></content:encoded>
			<wfw:commentRss>http://runmad.com/blog/2010/06/debugging-executables-for-push-notifcations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dedicated Static Analyzer Debug Configuration in Xcode</title>
		<link>http://runmad.com/blog/2009/12/dedicated-static-analyzer-debug-configuration-in-xcode/</link>
		<comments>http://runmad.com/blog/2009/12/dedicated-static-analyzer-debug-configuration-in-xcode/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 14:34:58 +0000</pubDate>
		<dc:creator>Rune Madsen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[analyze]]></category>
		<category><![CDATA[clang]]></category>
		<category><![CDATA[tech talk]]></category>

		<guid isPermaLink="false">http://www.davesenior.com/rune/?p=90</guid>
		<description><![CDATA[I went to iPhone Tech Talk in Toronto yesterday, and among the many sessions, I attended Michael Jurewitz&#8217; (@jurewitz) session, &#8220;Testing and Debugging Your iPhone Application.&#8221; He covered a lot of the basics for using Instruments (very similar to last year&#8217;s session on that), how to setup provisioning, etc. for Ad-Hoc Beta testing, etc. He [...]]]></description>
			<content:encoded><![CDATA[<p>I went to iPhone Tech Talk in Toronto yesterday, and among the many sessions, I attended Michael Jurewitz&#8217; (<a href="http://www.twitter.com/jurewitz">@jurewitz</a>) session, &#8220;Testing and Debugging Your iPhone Application.&#8221; He covered a lot of the basics for using Instruments (very similar to last year&#8217;s session on that), how to setup provisioning, etc. for Ad-Hoc Beta testing, etc.</p>
<p>He also covered Xcode&#8217;s new built in Static Analyzer (Clang), which is incredibly useful and powerful now that it&#8217;s a part of Xcode. However, I haven&#8217;t been using it that much (he said to use it <em>at least</em> once a week), but he briefly showed that there&#8217;s actually a setting in the project&#8217;s build settings called &#8220;Run Static Analyzer,&#8221; which is a checkbox and checking this will run the Static Analyzer every time you build your project. Jurewitz mentioned you could make a duplicate Debug build configuration that is dedicated to running the Static Analyzer.</p>
<p>He went over this very fast, so I think a lot of people missed the benefit of this great tip!</p>
<p>So here&#8217;s how you do it:</p>
<p>Open your project settings and go to the Configurations pane. Pick your Debug configuration (or whichever build configuration you want to dedicate to running the Static Analyzer) and hit Duplicate in the bottom of the window. I called mine &#8220;Debug with Clang,&#8221; so I know it&#8217;s my Debug build configuration.</p>
<p><a href="http://runmad.com/blog/wp-content/uploads/2009/12/Screen-shot-2010-05-10-at-8.36.33-PM.png"><img class="aligncenter size-full wp-image-133" title="Xcode Project Build Configurations" src="http://runmad.com/blog/wp-content/uploads/2009/12/Screen-shot-2010-05-10-at-8.36.33-PM.png" alt="" width="379" height="141" /></a></p>
<p>Next, hop into the Build pane and find &#8220;Build Options&#8221;. Within those options you&#8217;ll find the &#8220;Run Static Analyzer&#8221; option. Check the checkbox and you&#8217;re good to go!</p>
<p><a href="http://runmad.com/blog/wp-content/uploads/2009/12/Run_Clang_Option1.png"><img class="aligncenter size-full wp-image-135" title="Run With Clang/Static Analyzer Option In Xcode" src="http://runmad.com/blog/wp-content/uploads/2009/12/Run_Clang_Option1.png" alt="" width="331" height="140" /></a></p>
<p>Now, every time you build your project using your new &#8220;Debug with Clang&#8221; it&#8217;ll automatically analyze your project. Personally it&#8217;ll probably help me remember to run the Static Analyzer way more often on my project, instead of just once in a while.</p>
<p>Keep in mind that running the Static Analyzer increases the time it takes to build your project, so don&#8217;t choose that build setting if you&#8217;re just testing new code, etc. Also, I find it&#8217;s a good idea to &#8220;Clean All Targets&#8221; once in while, as it seems to &#8216;reset&#8217; the Static Analyzer, because otherwise I am finding that it tends to miss certain errors on the second, third, fourth, etc. time you build with the &#8220;Run Static Analyzer&#8221; option on.</p>
]]></content:encoded>
			<wfw:commentRss>http://runmad.com/blog/2009/12/dedicated-static-analyzer-debug-configuration-in-xcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

