<?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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>iPhone Development Blog</title>
	
	<link>http://iPhoneIncubator.com/blog</link>
	<description>Tips and Tricks for iPhone SDK Developers</description>
	<lastBuildDate>Tue, 03 Nov 2009 00:48:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/IphoneDevelopment" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>The iPhone Development Blog Named a Top 10 Blog by oDesk</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/A-0bOXWoyD8/the-iphone-development-blog-named-a-top-10-blog-by-odesk</link>
		<comments>http://iPhoneIncubator.com/blog/general/the-iphone-development-blog-named-a-top-10-blog-by-odesk#comments</comments>
		<pubDate>Mon, 02 Nov 2009 22:15:24 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=351</guid>
		<description><![CDATA[Thank you oDesk!
To all new visitors from oDesk: Welcome! If you like what you see here, click on the orange button in the top right corner of each page to subscribe to the RSS feed.
You should also check out the other blogs on the list. They&#8217;re all on my daily reading list.
Post from iPhone Development [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/the-iphone-development-blog-named-a-top-10-blog-by-odesk">The iPhone Development Blog Named a Top 10 Blog by oDesk</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Thank you oDesk!</p>
<p>To all new visitors from oDesk: Welcome! If you like what you see here, click on the orange button in the top right corner of each page to <a href="http://feeds2.feedburner.com/IphoneDevelopment">subscribe to the RSS feed</a>.</p>
<p>You should also check out the other blogs on the <a href="http://www.odesk.com/blog/2009/11/top-10-iphone-development-blogs/">list</a>. They&#8217;re all on my daily reading list.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/the-iphone-development-blog-named-a-top-10-blog-by-odesk">The iPhone Development Blog Named a Top 10 Blog by oDesk</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/A-0bOXWoyD8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/general/the-iphone-development-blog-named-a-top-10-blog-by-odesk/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/general/the-iphone-development-blog-named-a-top-10-blog-by-odesk</feedburner:origLink></item>
		<item>
		<title>UIWebView:  Dynamically Modify HTML documents</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/SEDDiHX4Zzg/uiwebview-dynamically-modify-html-documents</link>
		<comments>http://iPhoneIncubator.com/blog/windows-views/uiwebview-dynamically-modify-html-documents#comments</comments>
		<pubDate>Sat, 31 Oct 2009 01:58:38 +0000</pubDate>
		<dc:creator>Jess</dc:creator>
				<category><![CDATA[Windows & Views]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[UIWebView]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=330</guid>
		<description><![CDATA[For a recent project I encountered the following requirements:

Download and store HTML documents that are rendered using the UIWebView class.
Download and store the external documents referenced in the HTML, like images, so that they, along with the HTML documents, are available in non-networked situations.
Use the same HTML documents and external documents as the body of [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/windows-views/uiwebview-dynamically-modify-html-documents">UIWebView:  Dynamically Modify HTML documents</a></p>
]]></description>
			<content:encoded><![CDATA[<p>For a recent project I encountered the following requirements:</p>
<ol>
<li>Download and store HTML documents that are rendered using the UIWebView class.</li>
<li>Download and store the external documents referenced in the HTML, like images, so that they, along with the HTML documents, are available in non-networked situations.</li>
<li>Use the same HTML documents and external documents as the body of in-app generated Emails.</li>
</ol>
<p>The challenge was to devise a scheme whereby the same HTML documents can be used for both rendering content within the app under non-networked situations and to provide the exact same user experience within the Email body; a clear Catch-22!</p>
<p>There are a number of possible approaches (see page 10 of <a href="http://iPhoneIncubator.com/blog/windows-views/360idev-iphone-developers-conference-presentation">Nick&#8217;s presentation</a>, but the one we choose was to use complete URL&#8217;s for all externally referenced documents within the HTML (for example, all images are referenced on a CDN).  We choose this route as it provides the simplest way to support the Email requirement.</p>
<p>Next we had to figure out a way to modify these URL&#8217;s dynamically to reference the same external documents located locally on the device.  To do this we use some features of UIWebView and Javascript.</p>
<p>First we set up the UIWebView and implement the webViewDidFinishLoad delegate method to kick off the Javascript.  Below you can see we take advantage of the webview&#8217;s stringByEvaluatingJavaScriptFromString() method to call our Javascript event listener useLocalPaths().</p>
<pre name="code" class="c">- (void)webViewDidFinishLoad:(UIWebView *)webView {
  DLog(@"Local URLs used = %@",[webView stringByEvaluatingJavaScriptFromString: @"window.useLocalPaths()"]);
}
</pre>
<p>The Javascript for the event listener is the following:  </p>
<pre name="code" class="html">&lt;script type="text/javascript"&gt;
  window.addEventListener('load',function() {
    window.useLocalPaths = function() {
      var images = document.getElementsByTagName('img');
      for (var i=0; i&lt;images.length; i++) {
        var url = images[i].src;
        if (url.length&gt;0) {
          var bits = url.split('/');
          images[i].src = bits[bits.length-1];
        }
      }
      return true;
    };
  },false);
&lt;/script&gt;
</pre>
<p>In this case, this event listener queries for all image tags and modifies the src attribute by stripping all of the URL except for the image file name.  For example if our image tag looked like this,</p>
<pre name="code" class="html">&lt;img src="http://www.pervasentcdn.com/pervasent.jpg" class="logo" alt="Pervasent" /&gt;</pre>
<p>it would be come this</p>
<pre name="code" class="html">&lt;img src="pervasent.jpg" class="logo" alt="Pervasent" /&gt;</pre>
<p>and thus achieves our goal.</p>
<p>It&#8217;s worth noting that the general approach of using UIWebView + Javascript is quite handy and obviously has many possible applications.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/windows-views/uiwebview-dynamically-modify-html-documents">UIWebView:  Dynamically Modify HTML documents</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/SEDDiHX4Zzg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/windows-views/uiwebview-dynamically-modify-html-documents/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/windows-views/uiwebview-dynamically-modify-html-documents</feedburner:origLink></item>
		<item>
		<title>In App Purchase – Roundup</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/D0dN0YGngt8/in-app-purchase-roundup</link>
		<comments>http://iPhoneIncubator.com/blog/general/in-app-purchase-roundup#comments</comments>
		<pubDate>Sat, 24 Oct 2009 02:00:05 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[In App Purchase]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=316</guid>
		<description><![CDATA[In the last week a lot has been written about Apple&#8217;s change to allow In App Purchase in free apps. Here are some of the more informative articles I&#8217;ve found:
Thoughts on In-App-Purchasing For Free Apps
A thorough post by Jeff Scott at 148Apps describing the good news and the bad news for both developers and consumers.
In-App [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/in-app-purchase-roundup">In App Purchase &#8211; Roundup</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In the last week a lot has been written about Apple&#8217;s change to allow In App Purchase in free apps. Here are some of the more informative articles I&#8217;ve found:</p>
<p><strong><a href="http://www.148apps.com/news/apppurchasing-free-apps-thoughts/">Thoughts on In-App-Purchasing For Free Apps</a></strong><br />
A thorough post by Jeff Scott at 148Apps describing the good news and the bad news for both developers and consumers.</p>
<p><strong><a href="http://blogs.computerworld.com/14928/in_app_purchases_could_fundamentally_change_apples_app_store">In-App purchases could fundamentally change Apple&#8217;s App Store</a></strong><br />
Seth Weintraub at ComputerWorld postulates that everything will change. The (unanswered) question is how?</p>
<p><strong><a href="http://www.marco.org/214082853">In-App Purchase now available for free apps</a></strong><br />
Marco Arment was one of the first iPhone developers to comment on the change.</p>
<p><strong><a href="http://www.tuaw.com/2009/10/15/apple-relents-in-app-purchase-for-free-apps-allows-demo-to-paid/">Apple relents: in-app purchase for free apps allows demo-to-paid</a></strong><br />
Another good developer summary by Erica Sadun at TUAW.</p>
<p><strong><a href="http://normalkid.com/2009/10/16/free-in-app-purchases-will-change-nothing/">Free In-App Purchases Will Change…. Little?</a></strong><br />
A somewhat pessimistic look at In App Purchase by Arnold Kim.</p>
<p><strong><a href="http://blog.off-by-one.mobi/2009/10/in-app-purchase-and-state-of-iphone.html">In App Purchase and the state of iPhone piracy</a></strong><br />
Much has been written about Apple&#8217;s statement that <em>&#8220;Using In App Purchase in your app can also help combat some of the problems of software piracy by allowing you to verify In App Purchases&#8221;</em>. Most of it has been ill-informed speculations by non-developers. In this post Dominique Bongard goes into great depth about the challenges of using In App Purchase to combat piracy. It&#8217;s not from a developers perspective, but from someone who has been involved in anti-piracy monitoring.</p>
<p><strong>Do In App Purchases count towards the Top Grossing list?</strong><br />
This is one of the questions I asked in my <a href="http://www.pervasent.com/news/in-app-purchase-for-free-apps">original article</a>. The answer seems to be yes. Freeverse <a href="http://blog.freeverse.com/monkeyblog/archives/2009/10/freeverse-revea.php">analyzed</a> the rankings of three of their games on the Top Paid list vs. the Top Grossing list. And Distmo <a href="http://blog.distimo.com/2009_10_free-apps-penetrating-top-grossing-rankings-on-apples-app-store/">discovered</a> that several free apps have made it onto the Top Grossing list.</p>
<p><strong>iTunes Connect Updated</strong><br />
On October 22 Apple made an update to iTunes Connect. After this update I was finally able to add In App Purchase to free apps, and it was also possible to change the price of an existing app with In App Purchase to free. </p>
<p><strong>iPhone Developer Program License Agreement Updated</strong><br />
When you login to iPhone Dev Center you will be prompted to accept a new iPhone Developer Program License Agreement. I have not compared the entire document against the previous version, but one thing that I noticed had changed was specifically to allow for In App Purchase in free apps.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/in-app-purchase-roundup">In App Purchase &#8211; Roundup</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/D0dN0YGngt8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/general/in-app-purchase-roundup/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/general/in-app-purchase-roundup</feedburner:origLink></item>
		<item>
		<title>Thanks For The Feedback</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/pf99NVlU75M/thanks-for-the-feedback</link>
		<comments>http://iPhoneIncubator.com/blog/general/thanks-for-the-feedback#comments</comments>
		<pubDate>Tue, 20 Oct 2009 00:09:49 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=311</guid>
		<description><![CDATA[I just received my session survey feedback from 360&#124;iDev Denver 2009:

Agree that the Session was Informative? 100%
Agree that the Speaker was Authoritative? 100%
Agree that the Session was What you Expected? 100%
Overall rating (1-5, 5 being best) Avg : 5

Wow! I could literally not have asked for anything more. Thank you to all of you who [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/thanks-for-the-feedback">Thanks For The Feedback</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I just received my session survey feedback from <a href="http://www.360idev.com/about/denver-2009">360|iDev Denver 2009</a>:</p>
<ul>
<li>Agree that the Session was Informative? 100%</li>
<li>Agree that the Speaker was Authoritative? 100%</li>
<li>Agree that the Session was What you Expected? 100%</li>
<li>Overall rating (1-5, 5 being best) Avg : 5</li>
</ul>
<p>Wow! I could <em>literally</em> not have asked for anything more. Thank you to all of you who attended my talk. If you have not checked out the presentation, it&#8217;s available here: <a href="http://iPhoneIncubator.com/blog/windows-views/360idev-iphone-developers-conference-presentation">UIWebView – The Most Versatile Class in UIKit</a>.</p>
<p>While on the topic of feedback, feel free to suggest topics you would like to see covered here on the iPhone Development Blog in the future. Is there anything you would like to see more of? Less? Comments are open.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/thanks-for-the-feedback">Thanks For The Feedback</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/pf99NVlU75M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/general/thanks-for-the-feedback/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/general/thanks-for-the-feedback</feedburner:origLink></item>
		<item>
		<title>Are You Serious About Becoming An iPhone Developer?</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/RjGXUVAQlCM/are-you-serious-about-becoming-an-iphone-developer</link>
		<comments>http://iPhoneIncubator.com/blog/general/are-you-serious-about-becoming-an-iphone-developer#comments</comments>
		<pubDate>Fri, 16 Oct 2009 20:33:18 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=305</guid>
		<description><![CDATA[Back in the old days while the NDA was still in effect, us old-time developers had to walk miles through snow without shoes to find any information about iPhone development and the iPhone SDK. These days, there&#8217;s too much information available and it&#8217;s hard to know where to start.
It&#8217;s great if you have a veteran [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/are-you-serious-about-becoming-an-iphone-developer">Are You Serious About Becoming An iPhone Developer?</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Back in the old days while the NDA was still in effect, us old-time developers had to walk miles through snow without shoes to find any information about iPhone development and the iPhone SDK. These days, there&#8217;s too much information available and it&#8217;s hard to know where to start.</p>
<p>It&#8217;s great if you have a veteran iPhone developer at your side to guide you through the jungle. To make sure that you understand the Cocoa Touch principles, get a good application architecture in place from the start, etc, etc.</p>
<p>Luckily you can have one of the best teachers in the business by your side for two days to get you started the right way. Dan Grigsby of Mobile Orchard fame is teaching his Two Day Beginning iPhone Programming Training Class in Portland, Nov 12-13 and in Los Angeles, Nov 19-20. You don&#8217;t need any iPhone or Mac programming experience before the class, but you should have some prior development experience, e.g. being a web developer.</p>
<p>More information <a href="http://www.mobileorchard.com/iphone-programming-training-class/">here</a>. If you enter the coupon code &#8220;nick&#8221;, you&#8217;ll get a nice discount if you sign up during early registration. (And no, I&#8217;m not getting any kickbacks on this.)</p>
<p>If you&#8217;re already past the beginner level, then you should definitely subscribe to the <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=294369513">Mobile Orchard Podcast</a>. It has great interviews with iPhone developers and gets into wonderfully gory details about iPhone programming and other development issues.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/are-you-serious-about-becoming-an-iphone-developer">Are You Serious About Becoming An iPhone Developer?</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/RjGXUVAQlCM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/general/are-you-serious-about-becoming-an-iphone-developer/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/general/are-you-serious-about-becoming-an-iphone-developer</feedburner:origLink></item>
		<item>
		<title>In App Purchase for Free Apps</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/PN5O2jQBBI0/in-app-purchase-for-free-apps</link>
		<comments>http://iPhoneIncubator.com/blog/general/in-app-purchase-for-free-apps#comments</comments>
		<pubDate>Thu, 15 Oct 2009 19:51:33 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[In App Purchsae]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=302</guid>
		<description><![CDATA[I just wrote a blog post on our corporate blog about Apple&#8217;s announcement that In App Purchase is now allowed for free apps. This is a huge change and you should know how it impacts you as a developer.
Post from iPhone Development Blog Copyright &#169; 2009 Nick Dalton - iPhone DeveloperIn App Purchase for Free [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/in-app-purchase-for-free-apps">In App Purchase for Free Apps</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I just wrote a <a href="http://www.pervasent.com/">blog post</a> on our corporate blog about Apple&#8217;s announcement that In App Purchase is now allowed for free apps. This is a huge change and you should know how it impacts you as a developer.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/in-app-purchase-for-free-apps">In App Purchase for Free Apps</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/PN5O2jQBBI0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/general/in-app-purchase-for-free-apps/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/general/in-app-purchase-for-free-apps</feedburner:origLink></item>
		<item>
		<title>How To Obtain Total and Available Disk Space on Your iPhone or iPod Touch</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/92d159Le93g/how-to-obtain-total-and-available-disk-space-on-your-iphone-or-ipod-touch</link>
		<comments>http://iPhoneIncubator.com/blog/device-information/how-to-obtain-total-and-available-disk-space-on-your-iphone-or-ipod-touch#comments</comments>
		<pubDate>Thu, 08 Oct 2009 19:12:53 +0000</pubDate>
		<dc:creator>Jess</dc:creator>
				<category><![CDATA[Device Information]]></category>
		<category><![CDATA[NSFileManager]]></category>
		<category><![CDATA[NSFileSystemSize]]></category>
		<category><![CDATA[statfs]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=290</guid>
		<description><![CDATA[A quick Internet search to find out how to get the disk space on a device showed a number of blog posts that proposed solutions similar to this:
#include &#60;sys/param.h&#62;
#include &#60;sys/mount.h&#62;

+(float)getTotalDiskSpaceInBytes {
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	struct statfs tStats;
	statfs([[paths lastObject] cString], &#038;tStats);
	float totalSpace = (float)(tStats.f_blocks * tStats.f_bsize);

    return totalSpace;
}

This approach relies on the [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/device-information/how-to-obtain-total-and-available-disk-space-on-your-iphone-or-ipod-touch">How To Obtain Total and Available Disk Space on Your iPhone or iPod Touch</a></p>
]]></description>
			<content:encoded><![CDATA[<p>A quick Internet search to find out how to get the disk space on a device showed a number of blog posts that proposed solutions similar to this:</p>
<pre name="code" class="c">#include &lt;sys/param.h&gt;
#include &lt;sys/mount.h&gt;

+(float)getTotalDiskSpaceInBytes {
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	struct statfs tStats;
	statfs([[paths lastObject] cString], &#038;tStats);
	float totalSpace = (float)(tStats.f_blocks * tStats.f_bsize);

    return totalSpace;
}
</pre>
<p>This approach relies on the handy Unix statfs() function that provides the required file system information. I coded it up and it worked on my 3.x devices.  Fine I thought, I&#8217;m off and running.  Then when testing on a 2.x device, it crashed.  The problem looks to be differences in the compiler settings between the two OS versions.  Rather than figure that out (I leave that as an exercise to the reader <img src='http://iPhoneIncubator.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ), I continued my search and came across what I consider the &#8220;correct&#8221; solution since it uses the iPhone SDK itself, as given below.</p>
<pre name="code" class="c">+(float)getTotalDiskSpaceInBytes {
	float totalSpace = 0.0f;
	NSError *error = nil;
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &#038;error];

	if (dictionary) {
		NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
		totalSpace = [fileSystemSizeInBytes floatValue];
	} else {
		DLog(@"Error Obtaining File System Info: Domain = %@, Code = %@", [error domain], [error code]);
	}

    return totalSpace;
}
</pre>
<p>As stated in the documentation, these interfaces wrapper the statfs() function, so they ultimately do the same thing, but they have been a part of the SDK since version 2.0!  Testing verified my assumption and this approach works for me on my 2.x and 3.x devices and the numbers match what iTunes shows as well.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/device-information/how-to-obtain-total-and-available-disk-space-on-your-iphone-or-ipod-touch">How To Obtain Total and Available Disk Space on Your iPhone or iPod Touch</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/92d159Le93g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/device-information/how-to-obtain-total-and-available-disk-space-on-your-iphone-or-ipod-touch/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/device-information/how-to-obtain-total-and-available-disk-space-on-your-iphone-or-ipod-touch</feedburner:origLink></item>
		<item>
		<title>360|iDev iPhone Developers Conference Presentation</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/yvvdqygnqtU/360idev-iphone-developers-conference-presentation</link>
		<comments>http://iPhoneIncubator.com/blog/windows-views/360idev-iphone-developers-conference-presentation#comments</comments>
		<pubDate>Sat, 03 Oct 2009 03:36:39 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Windows & Views]]></category>
		<category><![CDATA[UIWebView]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=284</guid>
		<description><![CDATA[This week I had the pleasure of both attending and speaking at the 360&#124;iDev iPhone Developers Conference in Denver. Tom and John did an awesome job organizing this conference and they managed to gather an amazing group of speakers and attendees.
My own humble talk was titled UIWebView &#8211; The Most Versatile Class in UIKit. A [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/windows-views/360idev-iphone-developers-conference-presentation">360|iDev iPhone Developers Conference Presentation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This week I had the pleasure of both attending and speaking at the<a href="http://www.360idev.com/denver-2009-speakers"> 360|iDev iPhone Developers Conference in Denver</a>. Tom and John did an awesome job organizing this conference and they managed to gather an amazing group of speakers and attendees.</p>
<p>My own humble talk was titled UIWebView &#8211; The Most Versatile Class in UIKit. A topic that should be familiar to longtime readers of this blog. For the presentation I also took the time to create complete working code examples. Another favorite request around here&#8230;</p>
<p>Here are the links to download the <a href="http://iPhoneIncubator.com/files/NickDalton_360iDev_Sept2009.pdf">presentation</a> and the <a href="http://iPhoneIncubator.com/files/iPhoneIncubator.tar.gz">sample code</a>.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/windows-views/360idev-iphone-developers-conference-presentation">360|iDev iPhone Developers Conference Presentation</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/yvvdqygnqtU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/windows-views/360idev-iphone-developers-conference-presentation/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/windows-views/360idev-iphone-developers-conference-presentation</feedburner:origLink></item>
		<item>
		<title>App Store Resource Center</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/mSPiroLWKKU/app-store-resource-center</link>
		<comments>http://iPhoneIncubator.com/blog/general/app-store-resource-center#comments</comments>
		<pubDate>Sat, 19 Sep 2009 03:18:02 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[App Store]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=281</guid>
		<description><![CDATA[Today Apple launched the new App Store Resource Center. Calling it &#8220;new&#8221; is actually a bit of a stretch, since it seems to be mostly a collection of information that was previously scattered in several places. But we should still give Apple credit for the effort. The are moving in the right direction.
I still think [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/app-store-resource-center">App Store Resource Center</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Today Apple launched the new <a href="https://developer.apple.com/iphone/appstore/">App Store Resource Center</a>. Calling it &#8220;new&#8221; is actually a bit of a stretch, since it seems to be mostly a collection of information that was previously scattered in several places. But we should still give Apple credit for the effort. The are moving in the right direction.</p>
<p>I still think my own <a href="http://iPhoneIncubator.com/blog/app-store/rejections">App Store Rejection Reasons</a> page is a good complement to Apple&#8217;s official documents. And I just updated the page with a few new items that I painfully encountered.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/general/app-store-resource-center">App Store Resource Center</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/mSPiroLWKKU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/general/app-store-resource-center/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/general/app-store-resource-center</feedburner:origLink></item>
		<item>
		<title>How To Add DEBUG Flag In A 3.0 Project In Xcode</title>
		<link>http://feedproxy.google.com/~r/IphoneDevelopment/~3/DT_83kPg0FQ/how-to-add-debug-flag-in-a-3-0-project-in-xcode</link>
		<comments>http://iPhoneIncubator.com/blog/xcode/how-to-add-debug-flag-in-a-3-0-project-in-xcode#comments</comments>
		<pubDate>Thu, 10 Sep 2009 16:14:04 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Xcode]]></category>
		<category><![CDATA[3.0]]></category>
		<category><![CDATA[GCC]]></category>

		<guid isPermaLink="false">http://iPhoneIncubator.com/blog/?p=268</guid>
		<description><![CDATA[In this post How To Create Conditional Log Statements in Xcode I described how you could add a DEBUG flag to your Xcode project setting so that you could use statements like #ifdef DEBUG in your code.
If you follow the instructions in the post for a 3.0 project you will get an error:
There’s already another key [...]<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/xcode/how-to-add-debug-flag-in-a-3-0-project-in-xcode">How To Add DEBUG Flag In A 3.0 Project In Xcode</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In this post <a href="http://iPhoneIncubator.com/blog/debugging/how-to-create-conditional-log-statements-in-xcode">How To Create Conditional Log Statements in Xcode</a> I described how you could add a DEBUG flag to your Xcode project setting so that you could use statements like #ifdef DEBUG in your code.</p>
<p>If you follow the instructions in the post for a 3.0 project you will get an error:</p>
<blockquote><p>There’s already another key named “GCC_PREPROCESSOR_DEFINITIONS”. Please enter a different name.</p></blockquote>
<p>If you scroll through all the build settings you will not find one labeled GCC_PREPROCESSOR_DEFINITIONS. This is because this setting has helpfully been relabeled &#8220;Preprocessor Macros&#8221; and is now listed under the heading GCC 4.2 &#8211; Preprocessing:</p>
<p style="text-align: center;"><a href="http://iPhoneIncubator.com/blog/wp-content/uploads/2009/09/PreprocessorMacros.png"><img class="aligncenter size-full wp-image-270" title="PreprocessorMacros" src="http://iPhoneIncubator.com/blog/wp-content/uploads/2009/09/PreprocessorMacros.png" alt="PreprocessorMacros" width="579" height="185" /></a></p>
<p>To find out how any of these new &#8220;helpful&#8221; labels are actually translated to compiler settings, click on the Research Assistant button at bottom left corner of the window (the button that looks like a pair of reading classes on top of a stack of books) and you&#8217;ll see this:</p>
<p style="text-align: center;"><a href="http://iPhoneIncubator.com/blog/wp-content/uploads/2009/09/ResearchAssitant.png"><img class="aligncenter size-full wp-image-271" title="ResearchAssitant" src="http://iPhoneIncubator.com/blog/wp-content/uploads/2009/09/ResearchAssitant.png" alt="Xcode Research Assitant" width="286" height="235" /></a></p>
<p>Note that I&#8217;ve only seen this change for projects that I&#8217;ve created in Xcode 3.1.3 (which by default only have a SDK 3.0 target). Projects that were created in older versions of Xcode (even if they can target SDK 3.0) still show the GCC_PREPROCESSOR_DEFINITIONS label under the heading User-Defined.</p>
<p>Post from <a href="http://iPhoneIncubator.com/blog">iPhone Development Blog</a> Copyright &copy; 2009 Nick Dalton - <a href="http://iPhoneIncubator.com/blog/portfolio">iPhone Developer</a><br/><br/><a href="http://iPhoneIncubator.com/blog/xcode/how-to-add-debug-flag-in-a-3-0-project-in-xcode">How To Add DEBUG Flag In A 3.0 Project In Xcode</a></p>
<img src="http://feeds.feedburner.com/~r/IphoneDevelopment/~4/DT_83kPg0FQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://iPhoneIncubator.com/blog/xcode/how-to-add-debug-flag-in-a-3-0-project-in-xcode/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://iPhoneIncubator.com/blog/xcode/how-to-add-debug-flag-in-a-3-0-project-in-xcode</feedburner:origLink></item>
	</channel>
</rss>
