<?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>Christian Beer</title>
	<atom:link href="http://chbeer.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://chbeer.de</link>
	<description>iPhone and iPad Software Developer</description>
	<lastBuildDate>Tue, 06 Jul 2010 15:59:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hands on tutorial to NSDateComponents</title>
		<link>http://chbeer.de/2010/07/hands-on-tutorial-to-nsdatecomponents/</link>
		<comments>http://chbeer.de/2010/07/hands-on-tutorial-to-nsdatecomponents/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 10:33:23 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://chbeer.de/?p=34</guid>
		<description><![CDATA[Calculating dates is quite a hard thing to do. You need to keep in mind that adding or subtracting days (or months, hours, &#8230;) to a date can lead to changing months or even years: Getting the date of &#8220;two days before the first of January&#8221; leads to substract a year and a month from [...]]]></description>
			<content:encoded><![CDATA[<p>Calculating dates is quite a hard thing to do. You need to keep in mind that adding or subtracting days (or months, hours, &#8230;) to a date can lead to changing months or even years: Getting the date of &#8220;two days before the first of January&#8221; leads to substract a year and a month from the current date, the result is the 29th of December a year before. You even need to keep leap years in mind.</p>
<p>But there are tools in Cocoa that takes all the heavy stuff off of calculating dates: the NSDate, NSCalendar and NSDateComponents classes. There are (at minimum) two things you can do using NSDateComponents: get components of a date and calculate new dates by changing components.</p>
<h3>Getting Date Components</h3>
<p>Getting date components of a given NSDate is very easy using NSDateComponents:</p>
<p><code>-(int)month:(NSDate*)date {<br />
NSDateComponents *comps = [[NSCalendar currentCalendar] components:NSMonthCalendarUnit<br />
fromDate:date];<br />
return comps.month;<br />
}</code></p>
<p>To access components of a given NSDate we are using NSCalendar to get a group of components of it. Here we are interested in the month. So at first we are asking NSCalendar for the NSMonthCalendarUnit of our given date.</p>
<p>After that we can access the specified units from the NSDateComponent. What&#8217;s important to know is that accessing units we didn&#8217;t specify on components:fromDate won&#8217;t give the correct values but more or less random values.</p>
<p>You can also use NSDateComponents to get a date that only contains the values for given components. For example you can get a NSDate that contains the beginning of the day without hours, minutes, seconds, etc.:</p>
<p><code><br />
NSDate *date = [NSDate date];<br />
NSDateComponents *comps = [[NSCalendar currentCalendar] components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit)<br />
fromDate:date];<br />
NSDate *beginningOfDay = [[NSCalendar currentCalendar] dateFromComponents:comps];<br />
</code></p>
<h3>Calculating New Dates</h3>
<p>To calculate new dates from a given date, you can configure a NSDateComponents instance as an offset to a date:</p>
<p><code>-(NSDate *)previousMonth:(NSDate*)date {<br />
NSDateComponents *comps = [[NSDateComponents alloc] init];<br />
[comps setMonth:-1];<br />
NSCalendar *cal = [NSCalendar currentCalendar];<br />
NSDate *date = [cal dateByAddingComponents:comps toDate:date options:0];<br />
[comps release];<br />
return date;<br />
}</code></p>
<p>At first we instantiate a NSDateComponent and configure it with the offsets we want to add to the NSDate. In this example we want to calculate the date a month before today so we set the month to -1.</p>
<p>After that we create a new NSDate by adding the components to the given date.</p>
<h3>Summary</h3>
<p>NSDateComponents provides some really great functionality for creating dates with only requested components and to calculate dates as offsets from a given date. The class ensures that the calculated date is valid.</p>
<p>For my projects I created a NSDate category that provides some convenient methods to get date components and calculated dates.</p>
]]></content:encoded>
			<wfw:commentRss>http://chbeer.de/2010/07/hands-on-tutorial-to-nsdatecomponents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>App I created now no. 1 of free Apps in Germany</title>
		<link>http://chbeer.de/2010/05/app-i-created-now-no-1-of-free-apps-in-germany/</link>
		<comments>http://chbeer.de/2010/05/app-i-created-now-no-1-of-free-apps-in-germany/#comments</comments>
		<pubDate>Sat, 01 May 2010 12:50:39 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://chbeer.de/?p=25</guid>
		<description><![CDATA[The App kaufDA Navigator I created for a customer did become no. 1 of free Apps in Germany   That is great news!
]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://img.skitch.com/20100501-eiea8im9gfwykdgfy3u9safnjs.jpg" alt="kaufDA Navigator in Top 25 free Apps" width="232" height="488" />The App <a href="http://itunes.com/apps/kaufda-navigator" onclick="urchinTracker('/outgoing/itunes.com/apps/kaufda-navigator?referer=');">kaufDA Navigator</a> I created for a customer did become no. 1 of free Apps in Germany <img src='http://chbeer.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  That is great news!</p>
]]></content:encoded>
			<wfw:commentRss>http://chbeer.de/2010/05/app-i-created-now-no-1-of-free-apps-in-germany/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Xcodes build system for iPhone + iPad projects</title>
		<link>http://chbeer.de/2010/04/using-xcodes-build-system-for-iphone-ipad-projects/</link>
		<comments>http://chbeer.de/2010/04/using-xcodes-build-system-for-iphone-ipad-projects/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 14:14:23 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://chbeer.de/?p=16</guid>
		<description><![CDATA[Some iPhone apps will be ported to the iPad as a separate app but share the same code base. Besides using #if to distinguish between the devices, the Xcode build system can be used to create separate and clean code for each device.]]></description>
			<content:encoded><![CDATA[<p>My iPhone app iVocabulary will be available for the iPad as a separate application, not as a universal app. This is because the iPad version should be a First Class application not a scaled-up &#8220;Economy&#8221; app (as mentioned <a href="http://pocketcyclone.com/2010/04/07/ipad-apps-economy-vs-first-class/#comments" onclick="urchinTracker('/outgoing/pocketcyclone.com/2010/04/07/ipad-apps-economy-vs-first-class/_comments?referer=');">here</a>). There will be many classes that are shared between both applications and therefore I build the apps from one Xcode project.</p>
<p>To distinguish between the devices in code, Apple advises to use something like this:<br />
<code>#if __IPHONE_OS_VERSION_MAX_ALLOWED &gt;= 30200<br />
MyIPadViewController* vc;<br />
// Create the iPad view controller<br />
#else<br />
MyIPhoneViewController* vc;<br />
// Create the iPhone view controller<br />
#endif</code></p>
<p>But this can get very tedious and error prone. If you&#8217;ve got classes that are mostly the same for both devices but differ in some methods, the Xcode build system comes to the rescue.</p>
<p>Lets assume your AppDelegate differs in one method that initializes a viewcontroller differently for both devices. You can build that method and surround both code blocks with the structure above. But there is a better way: You create two categories for your class: AppDelegate+iPhone and AppDelegate+iPad:</p>
<p><code>/// file AppDelegate.h<br />
@interface AppDelegate {<br />
  MentionedViewController *_viewController;<br />
}<br />
- (void)initMentionedViewController;<br />
@end</p>
<p>/// file AppDelegate.m<br />
@implementation AppDelegate<br />
- (void) applicationDidFinishLaunching {<br />
  ...<br />
  [self initMentionedViewController];<br />
}<br />
@end</p>
<p>/// file AppDelegate+iPhone.m<br />
@implementation AppDelegate (iPhone)<br />
- (void) initMentionedViewController {<br />
  ... do special iPhone stuff here ...<br />
}<br />
@end</p>
<p>/// file AppDelegate+iPad.m<br />
@implementation AppDelegate (iPad)<br />
- (void) initMentionedViewController {<br />
  ... do special iPad stuff here ...<br />
}<br />
@end</code></p>
<p>The important part is to define the targets of the categories .m-Files via the targets tab in the info screen:</p>
<div id="attachment_17" class="wp-caption aligncenter" style="width: 432px"><a href="http://chbeer.de/wp-content/uploads/2010/04/Screenshot-Xcode-Targets.png"><img class="size-full wp-image-17 " title="Screenshot-Xcode-Targets" src="http://chbeer.de/wp-content/uploads/2010/04/Screenshot-Xcode-Targets.png" alt="Screenshot Xcode Targets" width="422" height="156" /></a><p class="wp-caption-text">Xcode &quot;Targets&quot; tab</p></div>
<p>During the build, the Xcode build system includes the correct file and the other one will be left out. This way you get the same result as if you used the #if-constructs but with much cleaner and more transparent code.</p>
]]></content:encoded>
			<wfw:commentRss>http://chbeer.de/2010/04/using-xcodes-build-system-for-iphone-ipad-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ProVoc Cocoa style</title>
		<link>http://chbeer.de/2010/04/provoc-cocoa-style/</link>
		<comments>http://chbeer.de/2010/04/provoc-cocoa-style/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 18:29:02 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[ProVoc]]></category>

		<guid isPermaLink="false">http://chbeer.de/?p=11</guid>
		<description><![CDATA[While improving ProVoc for the next iVocabulary version (to add synchronization) I am currently refactoring the looks of ProVoc to look a lot more mature and Cocoa like.
Here is a small example (labels are German):
]]></description>
			<content:encoded><![CDATA[<p>While improving ProVoc for the next iVocabulary version (to add synchronization) I am currently refactoring the looks of ProVoc to look a lot more mature and Cocoa like.</p>
<p>Here is a small example (labels are German):</p>
<div id="attachment_12" class="wp-caption alignleft" style="width: 618px"><a href="http://chbeer.de/wp-content/uploads/2010/04/Screenshot_ProVoc_Cocoa_1.png"><img class="size-full wp-image-12 " title="Screenshot_ProVoc_Cocoa_1" src="http://chbeer.de/wp-content/uploads/2010/04/Screenshot_ProVoc_Cocoa_1.png" alt="Screenshot ProVoc Cocoa-Style" width="608" height="371" /></a><p class="wp-caption-text">Screenshot ProVoc Cocoa-Style</p></div>
]]></content:encoded>
			<wfw:commentRss>http://chbeer.de/2010/04/provoc-cocoa-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross Compile ProVoc with Cocotron?</title>
		<link>http://chbeer.de/2010/03/cross-compile-provoc-with-cocotron/</link>
		<comments>http://chbeer.de/2010/03/cross-compile-provoc-with-cocotron/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 13:46:37 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Cocotron]]></category>
		<category><![CDATA[ProVoc]]></category>

		<guid isPermaLink="false">http://chbeer.de/?p=7</guid>
		<description><![CDATA[To build a vocabulary editor for Windows I considered building one in Java as the only option. But then I found the project Cocotron. Cocotron is an implementation of Cocoa for Windows and Linux (and could also be ported to other plattforms). It is easily integrated to Xcode so that you can build the Windows [...]]]></description>
			<content:encoded><![CDATA[<p>To build a vocabulary editor for Windows I considered building one in Java as the only option. But then I found the project Cocotron. Cocotron is an implementation of Cocoa for Windows and Linux (and could also be ported to other plattforms). It is easily integrated to Xcode so that you can build the Windows version of your application with few clicks.</p>
<p>For building Cocotron you need to <a href="http://www.cocotron.org/Tools/InstallCDT" onclick="urchinTracker('/outgoing/www.cocotron.org/Tools/InstallCDT?referer=');">install some tools</a>. These are downloaded and installed with few steps that are well documented on the Cocotron website. The navigation is not always clear on that website but you can find your way through it. The website itself is also coded in Objective-C and compiled for Linux using Cocotron.</p>
<p>After you installed the needed tools you can <a href="http://www.cocotron.org/Code/" onclick="urchinTracker('/outgoing/www.cocotron.org/Code/?referer=');">checkout</a> (or download) and compile Cocotron. For me the Cocoa project was all I had to build since it references some of the other needed packages. With the build process the library gets installed into the Developer folder.</p>
<p>The next step is to <a href="http://www.cocotron.org/Tools/Creating_Targets" onclick="urchinTracker('/outgoing/www.cocotron.org/Tools/Creating_Targets?referer=');">add a new target</a> to your existing (or new) project. You can easily do so by copying an existing Mac OS target and <a href="http://www.cocotron.org/Tools/Build_Settings" onclick="urchinTracker('/outgoing/www.cocotron.org/Tools/Build_Settings?referer=');">clean up and adapt the build settings</a>. That process is also well documented on the Cocotron website but it take some trial and error for me to find out if I did all I need. As soon as you don’t get any low level errors from gcc you can start porting your application. Depending on the complexity of your application it may use some parts of Cocoa that are not implemented in Cocotron by now.</p>
<p>For ProVoc the last part was not easy and is not finished by now. I added many <tt>#ifdef _WIN32</tt> and <tt>#ifndef __APPLE__</tt> to the code to disable unimplemented parts and it builds without errors (but with many warnings). ProVoc starts on Windows but there still seem to be some problems as it hangs shortly after starting. You can also <a href="http://www.cocotron.org/Tools/Debugging/Insight-GDB" onclick="urchinTracker('/outgoing/www.cocotron.org/Tools/Debugging/Insight-GDB?referer=');">debug your application on Windows using Insight-GDB</a> what I started to do at last.</p>
<p>As soon as I find some free time I will continue trying to get ProVoc run on Windows and I will post my findings here.</p>
]]></content:encoded>
			<wfw:commentRss>http://chbeer.de/2010/03/cross-compile-provoc-with-cocotron/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wordpress DB got deleted&#8230;</title>
		<link>http://chbeer.de/2010/03/wordpress-db-got-deleted/</link>
		<comments>http://chbeer.de/2010/03/wordpress-db-got-deleted/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 13:45:30 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://chbeer.de/?p=5</guid>
		<description><![CDATA[Sorry folks, I accidentially deleted the database of my wordpress installation (copy&#038;paste error). But I am checking googles cache to get the content back on my page&#8230;
]]></description>
			<content:encoded><![CDATA[<p>Sorry folks, I accidentially deleted the database of my wordpress installation (copy&#038;paste error). But I am checking googles cache to get the content back on my page&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://chbeer.de/2010/03/wordpress-db-got-deleted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
