<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2japanesefull.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>boreal-kiss.net</title>
	
	<link>http://blog.boreal-kiss.net</link>
	<description>Technical topics about Cocoa and Cocoa touch.</description>
	<lastBuildDate>Thu, 12 Jan 2012 09:54:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/bbknet" /><feedburner:info uri="bbknet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Minimal Template updated for iOS 5 with storyboards</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/i2eh90D7mO8/</link>
		<comments>http://blog.boreal-kiss.net/2012/01/12/minimal-template-updated-for-ios-5-with-storyboards/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 09:14:26 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=882</guid>
		<description><![CDATA[My project template for iOS working on Xcode 4 has been updated. I use a storyboard file (iOS 5 and later) rather than xib. Since all the source code including the content of the storyboard is not hard-coded in the template, You can easily modify their contents without having a catastrophe (adding/removing files needs some [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2012/01/Screen-Shot-2012-01-12-at-9.44.38.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2012/01/Screen-Shot-2012-01-12-at-9.44.38-300x202.png" alt="Minimal Template for iOS 5" title="Minimal Template for iOS 5" width="300" height="202" class="aligncenter size-medium wp-image-883" /></a></p>
<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2012/01/Screen-Shot-2012-01-12-at-9.45.14.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2012/01/Screen-Shot-2012-01-12-at-9.45.14-300x202.png" alt="Minimal Template for iOS 5 part2" title="Minimal Template for iOS 5 part2" width="300" height="202" class="aligncenter size-medium wp-image-884" /></a></p>
<p><a href="http://blog.boreal-kiss.net/2011/03/11/a-minimal-project-template-for-xcode-4/">My project template</a> for iOS working on Xcode 4 has been updated. I use a storyboard file (iOS 5 and later) rather than xib. Since all the source code including the content of the storyboard is not hard-coded in the template, You can easily modify their contents without having a catastrophe (adding/removing files needs some efforts though). If you are not familiar with storybords, the following guide will be helpful:</p>
<ul>
<li><a href="http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html">View Controller Programming Guide for iOS &#8211; iOS Developer Library</a></li>
</ul>
<p>You can find the complete template at my repository:</p>
<ul>
<li><a href="https://github.com/borealkiss/Minimal-Template">borealkiss/Minimal-Template &#8211; GitHub</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2012/01/12/minimal-template-updated-for-ios-5-with-storyboards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2012/01/12/minimal-template-updated-for-ios-5-with-storyboards/</feedburner:origLink></item>
		<item>
		<title>Removing conditional specific to a universal application</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/uNTSywSylXM/</link>
		<comments>http://blog.boreal-kiss.net/2011/12/22/removing-conditional-specific-to-a-universal-application/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 18:44:05 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=768</guid>
		<description><![CDATA[In order to make an application universal one has to detect the device&#8217;s idiom (iPhone/iPad) at run time. This is easily done with the following conditional: if &#40;UI_USER_INTERFACE_IDIOM&#40;&#41; == UIUserInterfaceIdiomPad&#41;&#123; //iPad specific codes. &#125; else&#123; //iPhone specific codes. &#125; You might have used this conditional, for example, when you want to control a view&#8217;s rotation [...]]]></description>
			<content:encoded><![CDATA[<p>In order to make an application universal one has to detect the device&#8217;s idiom (iPhone/iPad) at run time. This is easily done with the following conditional:</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>UI_USER_INTERFACE_IDIOM<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> UIUserInterfaceIdiomPad<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">//iPad specific codes.</span>
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">else</span><span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">//iPhone specific codes.</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>You might have used this conditional, for example, when you want to control a view&#8217;s rotation or a modal view&#8217;s behavior depending on the current device&#8217;s idiom. The above conditional is simple and easy to implement when the application is simple. However once the application has lots of behaviors varying on the device&#8217;s idiom here and there, your source codes will get messy and hard to read and/or maintain, due to the duplication of this snippet spreading over your project.</p>
<p>Fortunately this will be easily resolved by using the well known <a href="http://en.wikipedia.org/wiki/State_pattern">State pattern</a>. As the name suggests, State pattern deals with the internal state of its participating context and does some work without unnecessarily exposing other states that the context could have. As describing such patterns only in words is always hard to figure out, I&#8217;ll give you an example to walk through with.</p>
<h2>Example</h2>
<p>Consider the following situation. You want to control a view&#8217;s rotation depending on the device&#8217;s idiom:</p>
<ul>
<li>On iPhone, the application allows one of portrait modes (Home button at the bottom).</li>
<li>On iPad, the application allows both portrait and landscape modes.</li>
</ul>
<p>The implementation for this in a straightforward way looks like this:</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;">BOOL</span><span style="color: #002200;">&#41;</span>shouldAutorotateToInterfaceOrientation<span style="color: #002200;">:</span>
					<span style="color: #002200;">&#40;</span>UIInterfaceOrientation<span style="color: #002200;">&#41;</span>interfaceOrientation<span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>UI_USER_INTERFACE_IDIOM<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> UIUserInterfaceIdiomPad<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">//iPad.</span>
		<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">else</span><span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">//iPhone.</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>orientation <span style="color: #002200;">==</span> UIInterfaceOrientationPortrait<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
		<span style="color: #002200;">&#125;</span>
		<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>In this example, I&#8217;ll add some tweaks for the above snippet to look cleaner. That is:</p>
<ol>
<li>Wrap the codes inside the conditional into a block object.</li>
<li>Register them in a dictionary object.</li>
<li>Retrieve the block object from the dictionary when needed.</li>
<li>Invoke the block.</li>
</ol>
<h3>1-2. Create blocks and register them in dictionaries</h3>
<p>The key trick here is wrapping into blocks will done for iPhone and iPad separately:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//For iPhone.</span>
<span style="color: #a61390;">BOOL</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span>blockiPhone<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span>UIInterfaceOrientation orientation<span style="color: #002200;">&#41;</span> <span style="color: #002200;">=</span> 
						<span style="color: #002200;">^</span><span style="color: #002200;">&#40;</span>UIInterfaceOrientation orientation<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>orientation <span style="color: #002200;">==</span> UIInterfaceOrientationPortrait<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
<span style="color: #002200;">&#125;</span>;
&nbsp;
<span style="color: #002200;">&#91;</span>_dictionaryForiPhone setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>blockiPhone copy<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span> 
						forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;viewRotation&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//For iPad.</span>
<span style="color: #a61390;">BOOL</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span>blockiPad<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span>UIInterfaceOrientation orientation<span style="color: #002200;">&#41;</span> <span style="color: #002200;">=</span> 
						<span style="color: #002200;">^</span><span style="color: #002200;">&#40;</span>UIInterfaceOrientation orientation<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span>;
&nbsp;
<span style="color: #002200;">&#91;</span>_dictionaryForiPad setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>blockiPad copy<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span> 
						forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">&quot;viewRotation&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Here the dictionary objects as a registry assume to be instance variables in the class.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSMutableDictionary</span> <span style="color: #002200;">*</span>_dictionaryForiPhone;
<span style="color: #400080;">NSMutableDictionary</span> <span style="color: #002200;">*</span>_dictionaryForiPad;</pre></div></div>

<p>Note that although the value of the key string here is arbitrary, you would better give a meaningful name for its later usage. Also note that since block objects are yet in the stack, they must be copied to the heap before adding to the collections.</p>
<h3>3. Retrieve blocks</h3>
<p>Then I provide a method retrieving a appropriate block object corresponding to the device&#8217;s idiom:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//Incomplete.</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>blockForKey<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>key<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>UI_USER_INTERFACE_IDIOM<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> UIUserInterfaceIdiomPad<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>_dictionaryForiPad objectForKey<span style="color: #002200;">:</span>key<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">else</span><span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>_dictionaryForiPhone objectForKey<span style="color: #002200;">:</span>key<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>This is redundant since the conditional inside the method gets evaluated each time the method gets called. So add I additional tweaks. These look like this;</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//Complete</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>blockForKey<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>key<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>_idiomDetected<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>UI_USER_INTERFACE_IDIOM<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> UIUserInterfaceIdiomPad<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
			_dictionaryForCurrentIdiom <span style="color: #002200;">=</span> _dictionaryForiPad;
		<span style="color: #002200;">&#125;</span>
		<span style="color: #a61390;">else</span><span style="color: #002200;">&#123;</span>
			_dictionaryForCurrentIdiom <span style="color: #002200;">=</span> _dictionaryForiPhone;
		<span style="color: #002200;">&#125;</span>
		_idiomDetected <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>_dictionaryForCurrentIdiom objectForKey<span style="color: #002200;">:</span>key<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Here two new instance variables are introduced:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">BOOL</span> _idiomDetected;
<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>_dictionaryForCurrentIdiom;</pre></div></div>

<p>The boolean value is used for testing whether the application already detected the device&#8217;s idiom or not. If detected the application skips the conditional. If not, the application tries to detect the current device&#8217;s idiom and assign the reference to the appropriate block dictionary to _dictionaryForCurrentIdiom. Doing this, block objects will be retrieved only from this referencing dictionary, hiding the fact that there are actually two different collections of blocks (iPhone/iPad), thanks to State pattern.</p>
<h3>4. Invoke blocks</h3>
<p>Finally the above method will get called in the right place:</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;">BOOL</span><span style="color: #002200;">&#41;</span>shouldAutorotateToInterfaceOrientation<span style="color: #002200;">:</span>
					<span style="color: #002200;">&#40;</span>UIInterfaceOrientation<span style="color: #002200;">&#41;</span>interfaceOrientation<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">BOOL</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">^</span>block<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span>UIInterfaceOrientation<span style="color: #002200;">&#41;</span> <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self blockForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;viewRotation&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">return</span> block<span style="color: #002200;">&#40;</span>interfaceOrientation<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Note that in order to invoke a block correctly one must know the type of the block properly (Since you are the adder of blocks, you must know well their types, right?).</p>
<p>Now my codes are free from conditional, looking very tidy. Although the example here is trivial, this pattern will give you its real strength when the application has more and more device specific behavior (controlling modal views, if iPhone 4S, if iPad 2, and so on).</p>
<h3>BKUIIdiomController</h3>
<p>If you want to try this but save your time, here is my idiom controller class. The class only has two APIs:</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>setBlockForiPhone<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>blockForiPhone 
				blockForiPad<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>blockForiPad forKey<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>key;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>blockForKey<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>key;</pre></div></div>

<p>The first method for registering blocks (one for iPhone, the other for iPad) associated with a given key string. The second is for retrieving an appropriate block for the current device&#8217;s idiom. You could easily understand how to use this if you read this article. The demo project with full source codes are below:</p>
<ul>
<li><a href="https://github.com/borealkiss/BKUIIdiomController">borealkiss/BKUIIdiomController &#8211; GitHub</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/12/22/removing-conditional-specific-to-a-universal-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/12/22/removing-conditional-specific-to-a-universal-application/</feedburner:origLink></item>
		<item>
		<title>Subclassing a singleton in a thread-safe manner</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/CJgvcBFlGOY/</link>
		<comments>http://blog.boreal-kiss.net/2011/10/12/subclassing-a-singleton-in-a-thread-safe-manner/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 11:27:05 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=675</guid>
		<description><![CDATA[Why subclassing? Because I&#8217;m bored by preparing a bare-bone singleton from scratch. +[NSObject initialize] is invoked only once in a thread-safe manner before a class object receives any message (for more detail see NSObject Class Reference). Therefore this method could be a good place for a singleton instance to be created. Here is my singleton [...]]]></description>
			<content:encoded><![CDATA[<p>Why subclassing? Because I&#8217;m bored by preparing a bare-bone singleton from scratch.</p>
<p>+[NSObject initialize] is invoked only once in a thread-safe manner before a class object receives any message (for more detail see <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html">NSObject Class Reference</a>). Therefore this method could be a good place for a singleton instance to be created. </p>
<p>Here is my singleton class. I won&#8217;t show the complete implementation here. To be robust you should control methods concerning allocation such as alloc, init, copy, etc. However these are not of importance here. To check these visit the following site:</p>
<ul>
<li><a href="https://github.com/borealkiss/BKSingleton">https://github.com/borealkiss/BKSingleton</a></li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//BKSingleton.h</span>
&nbsp;
<span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> BKSingleton <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span><span style="color: #002200;">&#123;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">/**
 * Returns a singleton instance.
 */</span>
<span style="color: #002200;">+</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sharedInstance;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//BKSingleton.m</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;BKSingleton.h&quot;</span>
&nbsp;
<span style="color: #a61390;">static</span> <span style="color: #400080;">NSMutableDictionary</span> <span style="color: #002200;">*</span>_dictionary <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
<span style="color: #a61390;">@implementation</span> BKSingleton
&nbsp;
<span style="color: #002200;">+</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sharedInstance<span style="color: #002200;">&#123;</span>
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>className <span style="color: #002200;">=</span> NSStringFromClass<span style="color: #002200;">&#40;</span>self<span style="color: #002200;">&#41;</span>;
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>_dictionary objectForKey<span style="color: #002200;">:</span>className<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">+</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>initialize<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>_dictionary<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		_dictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableDictionary</span> dictionary<span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>className <span style="color: #002200;">=</span> NSStringFromClass<span style="color: #002200;">&#40;</span>self<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span>_dictionary objectForKey<span style="color: #002200;">:</span>className<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>_dictionary setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span>className<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>When a subclass of this class is first received a message, the initialize method of this class is invoked (i.e., +[BKSingleton initialize]) unless this is overridden in the subclass. </p>
<p>The first trick here is that there is no hard-coded class names inside the initialize method (e.g., something like [MyClass alloc]). Thanks to this even the subclass is received its superclass&#8217;s initialize method, it is always instantiated by the correct class.</p>
<p>The second trick is that the instance of a subclass is stored in a static class dictionary associated with its class name if there is not such an object with the same key found in the dictionary. Doing this ensures that the dictionary holds a unique instance for each subclass.</p>
<p>Let&#8217;s see an example. There are two subclasses inherited from BKSingleton. They have nothing newly implemented.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//Singleton1</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;BKSingleton.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> Singleton1 <span style="color: #002200;">:</span> BKSingleton<span style="color: #002200;">&#123;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #a61390;">@implementation</span> Singleton1
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//Singleton2</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;BKSingleton.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> Singleton2 <span style="color: #002200;">:</span> BKSingleton<span style="color: #002200;">&#123;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #a61390;">@implementation</span> Singleton2
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>Then run the following code.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//main.m</span>
&nbsp;
<span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span>
<span style="color: #6e371a;">#import &quot;BKSingleton.h&quot;</span>
<span style="color: #6e371a;">#import &quot;Singleton1.h&quot;</span>
<span style="color: #6e371a;">#import &quot;Singleton2.h&quot;</span>
&nbsp;
<span style="color: #a61390;">int</span> main<span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> argc, <span style="color: #a61390;">char</span> <span style="color: #002200;">*</span>argv<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #400080;">NSAutoreleasePool</span> <span style="color: #002200;">*</span> pool <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSAutoreleasePool</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;BKSingleton: %@&quot;</span>, <span style="color: #002200;">&#91;</span>BKSingleton sharedInstance<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Singleton1: %@&quot;</span>, <span style="color: #002200;">&#91;</span>Singleton1 sharedInstance<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Singleton2: %@&quot;</span>, <span style="color: #002200;">&#91;</span>Singleton2 sharedInstance<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">//Once again</span>
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;BKSingleton: %@&quot;</span>, <span style="color: #002200;">&#91;</span>BKSingleton sharedInstance<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Singleton1: %@&quot;</span>, <span style="color: #002200;">&#91;</span>Singleton1 sharedInstance<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Singleton2: %@&quot;</span>, <span style="color: #002200;">&#91;</span>Singleton2 sharedInstance<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>pool release<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">return</span> <span style="color: #2400d9;">0</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>The output is the following, ensuring they are al unique, i.e., singletons.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">Test<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1153</span><span style="color: #002200;">:</span><span style="color: #2400d9;">207</span><span style="color: #002200;">&#93;</span> BKSingleton<span style="color: #002200;">:</span> &lt;BKSingleton<span style="color: #002200;">:</span> 0xe0a880&gt;
Test<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1153</span><span style="color: #002200;">:</span><span style="color: #2400d9;">207</span><span style="color: #002200;">&#93;</span> Singleton1<span style="color: #002200;">:</span> &lt;Singleton1<span style="color: #002200;">:</span> 0xe08d20&gt;
Test<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1153</span><span style="color: #002200;">:</span><span style="color: #2400d9;">207</span><span style="color: #002200;">&#93;</span> Singleton2<span style="color: #002200;">:</span> &lt;Singleton2<span style="color: #002200;">:</span> 0xe0b620&gt;
Test<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1153</span><span style="color: #002200;">:</span><span style="color: #2400d9;">207</span><span style="color: #002200;">&#93;</span> BKSingleton<span style="color: #002200;">:</span> &lt;BKSingleton<span style="color: #002200;">:</span> 0xe0a880&gt;
Test<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1153</span><span style="color: #002200;">:</span><span style="color: #2400d9;">207</span><span style="color: #002200;">&#93;</span> Singleton1<span style="color: #002200;">:</span> &lt;Singleton1<span style="color: #002200;">:</span> 0xe08d20&gt;
Test<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1153</span><span style="color: #002200;">:</span><span style="color: #2400d9;">207</span><span style="color: #002200;">&#93;</span> Singleton2<span style="color: #002200;">:</span> &lt;Singleton2<span style="color: #002200;">:</span> 0xe0b620&gt;</pre></div></div>

<h1>Related links</h1>
<ul>
<li><a href="http://stackoverflow.com/questions/145154/what-does-your-objective-c-singleton-look-like">design patterns &#8211; What does your Objective-C singleton look like? &#8211; Stack Overflow</a></li>
<li><a href="http://eschatologist.net/blog/?p=178">Eschatology : Singletons in Cocoa/Objective-C</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/10/12/subclassing-a-singleton-in-a-thread-safe-manner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/10/12/subclassing-a-singleton-in-a-thread-safe-manner/</feedburner:origLink></item>
		<item>
		<title>WinGen: A Chrome extension for lazy Mac users</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/IEAU1VVcEGI/</link>
		<comments>http://blog.boreal-kiss.net/2011/10/10/wingen/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 09:11:03 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Extensions]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=627</guid>
		<description><![CDATA[WinGen is a utility plugin for Goole Chrome. It offers the following functions for easier web browsing specifically concerning hyperlinks: Function 1 WinGen navigates a hyperlink in a new window without using the context menu (i.e., control + click). As a Mac user, when you want to open a new window for links on a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/10/wingen-concept-image.png" alt="wingen concept image" title="wingen concept image" width="431" height="577" class="aligncenter size-full wp-image-628" /></p>
<p><a href="http://7614.org/wingen/">WinGen</a> is a utility plugin for Goole Chrome. It offers the following functions for easier web browsing specifically concerning hyperlinks:</p>
<h2>Function 1</h2>
<p>WinGen navigates a hyperlink in a new window without using the context menu (i.e., control + click). As a Mac user, when you want to open a new window for links on a web page, you need to click the control key to popup the context menu to choose &#8220;open in new window&#8221;. This requires to use your both hands. With WinGen simply clicking the link and hold for a while navigates that page in a new window. Your another hand will be now free. Keep a cup of coffee.</p>
<h2>Function 2</h2>
<p>WinGen could disable forced new window specified by target=&#8221;_blank&#8221; attribution. Have you been bothered by lots of auto new window creation within one web site? With WinGen clicking such links won&#8217;t popup new windows.</p>
<h2>Function 3</h2>
<p>As a optional function, WinGen could disable hyperlinks themselves. Have you needed to copy some parts of the text within a hyperlink? I&#8217;m sure copying all the text from the hyperklink is easy but trying partial copying always navigates you into a different page for that link. With WinGen when you control+click on a link, WinGen gives you enable/disable hyperlink options (I&#8217;m sorry this requires the context menu. You need the both hands). </p>
<p>Let me show an example. I want to copy the word &#8220;spectator&#8221; from the link &#8220;What a spectator threw at Tiger Woods&#8221; (from today&#8217;s yahoo news).</p>
<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/10/wingen-disabling-hyperlinks-example-1.png" alt="wingen disabling hyperlinks example 1" title="wingen disabling hyperlinks example 1" width="409" height="270" class="aligncenter size-full wp-image-641" /></p>
<p>First of all I turn on this function from the WinGen option page (the function is off by default).</p>
<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/10/wingen-disable-hyperlinks.png" alt="wingen disable hyperlinks" title="wingen disable hyperlinks" width="578" height="67" class="aligncenter size-full wp-image-662" /></p>
<p>Control+clicking on the link popups the WinGen menu. Then I select &#8220;disable hyperlink&#8221;.</p>
<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/10/wingen-disabling-hyperlinks-example-2.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/10/wingen-disabling-hyperlinks-example-2-300x238.png" alt="wingen disabling hyperlinks example 2" title="wingen disabling hyperlinks example 2" width="300" height="238" class="aligncenter size-medium wp-image-642" /></a></p>
<p>Now the link is just a text so I can copy the word &#8220;spectator&#8221;. I could also restore the link by &#8220;enable hyperlink&#8221; after that.</p>
<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/10/wingen-disabling-hyperlinks-example-3.png" alt="wingen disabling hyperlinks example 3" title="wingen disabling hyperlinks example 3" width="409" height="216" class="aligncenter size-full wp-image-643" /></p>
<h2>Related links</h2>
<ul>
<li><a href="http://7614.org/wingen/">WinGen Homepage</a></li>
<li><a href="https://chrome.google.com/webstore/detail/ioboeaehmjmamdlfmggkfpacknmhelpg">WinGen on Chrome Web Store</a></li>
<li><a href="https://github.com/borealkiss/WinGen">borealkiss/WinGen &#8211; GitHub (for developers)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/10/10/wingen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/10/10/wingen/</feedburner:origLink></item>
		<item>
		<title>Moiré: an iPhone app generating Moiré patterns</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/bK7MiuXoy74/</link>
		<comments>http://blog.boreal-kiss.net/2011/04/28/moire-an-iphone-app-generating-moire-patterns/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 06:12:55 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=605</guid>
		<description><![CDATA[My newest iPhone app Moiré is ready. The app dynamically generates Moiré pattern, an interference pattern created by multiple regular patterns overlaid on each other. The app offers the following features: Simple interface. You can control the app without instructions. 36 basic patterns. The number of generated Moiré is infinity. Wallpaper creation. You can use [...]]]></description>
			<content:encoded><![CDATA[<p>My newest iPhone app <a href="http://925.7614.org">Moiré</a> is ready. The app dynamically generates <a href="http://en.wikipedia.org/wiki/Moir%C3%A9_pattern">Moiré pattern</a>, an interference pattern created by multiple regular patterns overlaid on each other. The app offers the following features:</p>
<ul>
<li>Simple interface. You can control the app without instructions.</li>
<li>36 basic patterns. The number of generated Moiré is infinity.</li>
<li>Wallpaper creation. You can use resultant images as a wallpaper of your device. </li>
</ul>
<p>Here are some example images. You can see more on <a href="http://7614.org/moire/">Moiré Homepage</a>.</p>
<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/moire-sc-01.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/moire-sc-01-159x300.png" alt="Moire 01" title="Moire 01" width="159" height="300" class="aligncenter size-medium wp-image-612" /></a><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/moire-sc-02.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/moire-sc-02-159x300.png" alt="Moire 02" title="Moire 02" width="159" height="300" class="aligncenter size-medium wp-image-613" /></a><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/moire-sc-03.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/moire-sc-03-159x300.png" alt="Moire 03" title="Moire 03" width="159" height="300" class="aligncenter size-medium wp-image-615" /></a></p>
<p>The app is greatly inspired by the book <a href="https://shop.gestalten.com/index.php/catalog/product/view/id/441">Moiré Index</a> by <a href="http://www.carstennicolai.de/">Carsten Nicolai</a>. Since the book doesn&#8217;t offer dynamic contents, I would like to do so.</p>
<h2>Now on App Store</h2>
<p>Moiré is now on App Store for $1.99.</p>
<p><a href="http://itunes.apple.com/us/app/moire/id432069455?mt=8"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/avail_on_app_store_black1.png" alt="Available on the App Store" title="Available on the App Store" width="163" height="57" class="aligncenter size-full wp-image-608" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/04/28/moire-an-iphone-app-generating-moire-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/04/28/moire-an-iphone-app-generating-moire-patterns/</feedburner:origLink></item>
		<item>
		<title>Nespresso Stock Checker 3.2: Onirio Limited Edition 2011 and more</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/8gGusqo8GFI/</link>
		<comments>http://blog.boreal-kiss.net/2011/04/26/nespresso-stock-checker-3.2/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 06:28:21 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=580</guid>
		<description><![CDATA[One of my iPhone apps Nespresso Stock Checker has been updated to version 3.2 including the following new features. What&#8217;s new in Version 3.2 Compatible with Onirio Limited Edition 2011 released on April. Show route on Maps. This function enables you to show a route from your location to a boutique using Maps app (external). [...]]]></description>
			<content:encoded><![CDATA[<p>One of my iPhone apps <a href="http://402.7614.org/">Nespresso Stock Checker</a> has been updated to version 3.2 including the following new features.</p>
<h2>What&#8217;s new in Version 3.2</h2>
<ul>
<li>Compatible with <a href="http://www.nespresso.com/onirio/">Onirio Limited Edition 2011</a> released on April.
<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/nsc3_2-1.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/nsc3_2-1-159x300.png" alt="NSC 3.2-1" title="NSC 3.2-1" width="159" height="300" class="aligncenter size-medium wp-image-585" /></a>
</li>
<li>Show route on Maps. This function enables you to show a route from your location to a boutique using Maps app (external).
<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/nsc3_2-2.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/nsc3_2-2-159x300.png" alt="NSC 3.2-2" title="NSC 3.2-2" width="159" height="300" class="aligncenter size-medium wp-image-587" /></a>
</li>
</ul>
<h2>Now on App Store</h2>
<p>Nespresso Stock Checker is now on App Store for $1.99.</p>
<p><a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=303443484&amp;mt=8"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/04/avail_on_app_store_black.png" alt="Available on the App Store" title="Available on the App Store" width="163" height="57" class="aligncenter size-full wp-image-583" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/04/26/nespresso-stock-checker-3.2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/04/26/nespresso-stock-checker-3.2/</feedburner:origLink></item>
		<item>
		<title>How to create universal static libraries on Xcode 4: the traditional way</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/zwrrmvkGhAk/</link>
		<comments>http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 17:11:53 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=432</guid>
		<description><![CDATA[[Note on 09.04.2011: This article will not be helpful unless you really need universal static libraries for distribution purposes etc. Instead, using workspace is a better way for daily development.] Introduction Creating static libraries universal for iPhone device and simulator is a little bit tricky. On Xcode 3.x, the major way takes something like the [...]]]></description>
			<content:encoded><![CDATA[<p>[Note on 09.04.2011: This article will not be helpful unless you really need universal static libraries for distribution purposes etc. Instead, using workspace is a better way for daily development.]</p>
<h1>Introduction</h1>
<p>Creating static libraries universal for iPhone device and simulator is a little bit tricky. On Xcode 3.x, the major way takes something like the following steps:</p>
<ul>
<li>Create a build for the device (the armv6 and armv7 architecture).</li>
<li>Create a build for the simulator (the i386 architecture).</li>
<li>Merge the above builds to create a universal build using <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/lipo.1.html">lipo</a>.</li>
</ul>
<p>Since Xcode, 4 a new command called archiving (Product > Archive) is introduced as a way to distribute applications and/or static libraries. At glance this is suitable to creating a universal libraries but is not. One can not select this option for the simulator environment (you will notice it is always grayed out). As such we still have to rely on the traditional way to create universal libraries (<sup><a href="http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/#footnote_0_432" id="identifier_0_432" class="footnote-link footnote-identifier-link" title=" Of course there could be a way to create a universal library on one scheme by tuning build settings but I have not found it by myself nor on the web.">1</a></sup>). </p>
<p>In this article I will show you how to create such a fat static library on Xcode 4. Because the place for product builds of each project are completely changed from those of Xcode 3.x, we have to make a slight effort tailoring it to the Xcode 4.</p>
<h1>How to do</h1>
<p>In the following example I will use my project called BKMovableVC. On your workspace you can use whatever name you want, of course.</p>
<h2>Step 1</h2>
<p>Create a new <em>Cocoa Touch Static Library</em> target (File > New > New Target > Framework &#038; Library) for the simulator environment. Naming is arbitrary as long as you can recognize (I named here BKMovableVC-iphonesimulator). Add related source files to the <em>Compile Source</em> pane and headers to <em>Copy Header</em> pane. For headers you can choose three possible places to put in, Public , Private, and Project (default is Project). For example if you choose Public, all headers will be automatically copied to the build directory, which is easy for me to continue following works.</p>
<p>[Note on 04.05.2011: There is a bug on Xcode 4; when all panes (<em>Public</em>, <em>Private</em>, and <em>Project</em>) in the <em>Copy Header</em> pane are closed or never opened before, pushing the add button causes a crash. Open one of them before adding files.]</p>
<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/target-simulator.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/target-simulator-300x230.png" alt="" title="target-simulator" width="300" height="230" class="aligncenter size-medium wp-image-457" /></a></p>
<p>From the <em>Edit Scheme</em> pane (Product > Edit Scheme), change its build configuration to <em>Release</em>. This enables you to create a <em>Release</em> build product once the build operation is done. This build operation supposes to be done on the simulator architecture (i386).</p>
<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/scheme-simulator.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/scheme-simulator-300x199.png" alt="" title="scheme-simulator" width="300" height="199" class="aligncenter size-medium wp-image-465" /></a></p>
<h2>Step 2</h2>
<p>Create a new static library target for the iPhone device environment. Naming is arbitrary but must be different from that of the simulator (I named here BKMovableVC-iphoneos). Add related source files and headers and change its build configuration to <em>Release</em>. Every step is just the same as that of the simulator except for the build architecture; this build operation supposes to be done on the device architecture (armv6 and armv7). </p>
<p>Now we have two targets, one for the device and the other for the simulator. When you build a product, the product will be placed under the following directory:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">~/Library/Developer/Xcode/DerivedData/</pre></div></div>

<p>This place is shared by build products of all projects created on Xcode 4, which is quite different from the legacy place found on Xcode 3.x (each project has its own build directory). For example, if the name of the project is BKMovableVC, the <em>Release</em> build product for the simulator will be placed at</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">~/Library/Developer/Xcode/DerivedData/BKMovableVC-xxxxxxx/
	Build/Products/Release-iphonesimulator/
	libBKMovableVC-iphonesimulator.a</pre></div></div>

<p>and that for the device will be found at</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">~/Library/Developer/Xcode/DerivedData/BKMovableVC-xxxxxxx/
	Build/Products/Release-iphoneos/
	libBKMovableVC-iphoneos.a</pre></div></div>

<p>where BKMovableVC-xxxxxxx is a unique directory name automatically assigned by Xcode 4. </p>
<h2>Step 3</h2>
<p>Let&#8217;s merge them using the lipo command. Create a new Aggregate target (File > New > New Target > Other). I named it here BKMovableVC-ios4.3-0.9. On the <em>Build Pheses</em> pane select <em>Add Run Script</em> from the <em>Add Build Phase</em> button on the bottom-left corner. </p>
<p><a rel="lightbox" href="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/target-aggregate.png"><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/target-aggregate-300x194.png" alt="" title="target-aggregate" width="300" height="194" class="aligncenter size-medium wp-image-561" /></a></p>
<p>Now we are about to run some scripts on the Run Script pane but here is a problem. How do we direct lipo to work with builds that are placed under the directory whose name is automatically assigned by Xcode 4 (e.g., BKMovableVC-xxxxxxx for the above case)? Fortunately it is easily solved by the Xcode 4 environment variable called ${BUILT_PRODUCTS_DIR}. This variable represents the path to the directory for a current build product. For example, when we create a <em>Release</em> build product for the simulator explained above, ${BUILT_PRODUCTS_DIR} corresponds to the following path:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">~/Library/Developer/Xcode/DerivedData/BKMovableVC-xxxxxxx/
	Build/Products/Release-iphonesimulator/</pre></div></div>

<p>Let&#8217;s continue. Write the following script on the <em>Run Script</em> pane. This lets lipo create a merged build product called libBKMovableVC-ios4.3-0.9.a (you can give it whatever name you want). If there is already the product with the same name lipo deletes it before the merge operation as shown in the first line.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">rm -rf ${BUILT_PRODUCTS_DIR}/libBKMovableVC-ios4.3-0.9.a
&nbsp;
lipo -create &quot;${BUILT_PRODUCTS_DIR}/../${BUILD_STYLE}-iphonesimulator/libBKMovableVC-iphonesimulator.a&quot; \
&quot;${BUILT_PRODUCTS_DIR}/libBKMovableVC-iphoneos.a&quot; -output \
&quot;${BUILT_PRODUCTS_DIR}/libBKMovableVC-ios4.3-0.9.a&quot;</pre></div></div>

<p>Here is one trick. In this script the path representation to previously created build products such as libBKMovableVC-iphonesimulator.a looks odd because of &#8220;/../&#8221;. This is because the environment variable ${BUILT_PRODUCTS_DIR} depends on a current build phase (iPhone device, simulator, <em>Debug</em>, <em>Release</em>). For example, if this script runs for the <em>Release</em> build of iPhone device, the variable ${BUILT_PRODUCTS_DIR} will represent</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">~/Library/Developer/Xcode/DerivedData/BKMovableVC-xxxxxxx/
	Build/Products/Release-iphoneos/</pre></div></div>

<p>However the build product for the simulator, libBKMovableVC-iphonesimulator.a, is not placed under this path, because it was created through a different build phase.</p>
<h1>Implementation</h1>
<p>Let&#8217;s do all the flows in order. Do the following:</p>
<ol>
<li>Build the target BKMovableVC-iphonesimulator on the simulator. The build phase must be <em>Release</em>.</li>
<li>Build the target BKMovableVC-iphoneos on the device. The build phase must be <em>Release</em>.</li>
<li>Build the target BKMovableVC-ios4.3-0.9. on the device. The build phase must be <em>Release</em>.</li>
</ol>
<p>Then you will have a static library universal for the device and simulator in the following directory:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">~/Library/Developer/Xcode/DerivedData/BKMovableVC-xxxxxxx/
	Build/Products/Release-iphoneos/
	BKMovableVC-ios4.3-0.9.a</pre></div></div>

<p>You will also have header files depending upon your configuration (see the text above).</p>
<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/universal-static-library.png" alt="" title="universal-static-library" width="428" height="440" class="aligncenter size-full wp-image-514" /></p>
<h1>Footnotes</h1><ol class="footnotes"><li id="footnote_0_432" class="footnote"> Of course there could be a way to create a universal library on one scheme by tuning build settings but I have not found it by myself nor on the web.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/</feedburner:origLink></item>
		<item>
		<title>A minimal project template for Xcode 4</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/u90MHwMOijg/</link>
		<comments>http://blog.boreal-kiss.net/2011/03/11/a-minimal-project-template-for-xcode-4/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 20:55:40 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=367</guid>
		<description><![CDATA[Introduction Many people have their own project- and/or file-templates for practical or aesthetic reasons. For example I don&#8217;t like the naming convention provided by Apple such as XXXX-Info.plist, XXXX-Prefix.pch, and XXXXAppDelegate for the project XXXX. On Xcode 3.x. it was relatively easy to modify them. Since Xcode 4, however, Apple introduced a new template format [...]]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Many people have their own project- and/or file-templates for practical or aesthetic reasons. For example I don&#8217;t like the naming convention provided by Apple such as XXXX-Info.plist, XXXX-Prefix.pch, and XXXXAppDelegate for the project XXXX.  On Xcode 3.x. it was relatively easy to modify them. Since Xcode 4, however, Apple introduced a new template format that is no longer compatible with those of Xcode. 3.x. This has often become topics among Apple&#8217;s developer forums, since there is no official information provided. You can see how it changes from the Xcode 4 built-in templates. They are under</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">/</span>Developer<span style="color: #002200;">/</span>Library<span style="color: #002200;">/</span>Xcode<span style="color: #002200;">/</span>Templates<span style="color: #002200;">/</span></pre></div></div>

<p>for Mac OS X stuffs and</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">/</span>Developer<span style="color: #002200;">/</span>Platforms<span style="color: #002200;">/</span>iPhoneOS.platform<span style="color: #002200;">/</span>Developer<span style="color: #002200;">/</span>Library<span style="color: #002200;">/</span>Xcode<span style="color: #002200;">/</span>Templates<span style="color: #002200;">/</span></pre></div></div>

<p>for iOS. If you add your own templates, the place you should use is under the following path:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">~<span style="color: #002200;">/</span>Library<span style="color: #002200;">/</span>Developer<span style="color: #002200;">/</span>Xcode<span style="color: #002200;">/</span>Templates<span style="color: #002200;">/</span></pre></div></div>

<p>The problem is that it is quite hard to create a custom template. For example, to copy and paste the built-in template to your place will not show up the template on Xcode 4 until you manually change its identifier in TemplateInfo.plist.</p>
<h1>TemplateInfo.plist</h1>
<p>TemplateInfo.plist is basically a setup file for a Xcode 4 project. When creating a project, Xcode 4 first reads this file to prepare all environment for you to get started. Each TemplateInfo.plist has own identifier for Xcode 4 to distinguish from others (and that&#8217;s why copy-and-pasting built-in template described above does not work as a user template). If you need your own templates, you should give them your own identifiers. For example, the Xcode 4 built-in template for window based iPhone application has the following identifier:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">com.apple.dt.unit.windowBasedApplication</pre></div></div>

<p>TemplateInfo.plist has something inheritance nature like classes of programming languages (and the identifier corresponds to the name of class). Xcode 4 reads a given TemplateInfo.plist and aggregates data from its ancestral files. For example, the following figure shows pedigree charts for the built-in window based iPhone application template.</p>
<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/com.apple_.Templates.png" alt="com.apple.Templates" title="com.apple.Templates" width="477" height="456" class="aligncenter size-full wp-image-374" /></p>
<p>You can see that the TemplateInfo.plist for the window based iPhone application template is the sixth generation from the top-most base file (com.apple.dt.unit.base). This demonstrates that when you want to customize a given TemplateInfo.plist and the place you want to change within comes from the ancestral files, you have to manipulate multiple files, i.e., it could be error prone. Since TemplateInfo.plist is just an XML file, there is no compile errors. Moreover the inheritance nature of XML files has no readability at all. In fact it seems Apple creates them not by coding but by automatic generation tools.</p>
<h1>A minimal project template</h1>
<p>This was originally just for me but since it founds to be useful I will share this with someone who wants to have own templates on Xcode 4. This contains several templates within but only shows up one window based application template on Xcode 4 (the identifier is com.borealkiss.windowBasedApplication), because the others are not a concrete template (there are abstract templates not to be actually implemented). The following figure shows the contents (gray and orange ones are included):</p>
<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/com.borealkiss.Templates.png" alt="om.borealkiss.Templates" title="com.borealkiss.Templates" width="500" height="439" class="aligncenter size-full wp-image-390" /></p>
<p>This template enables you to manipulate in the old way as of Xcode 3.x, i.e., editing actual files and adding onto templates. Basically you only have to manipulate the TemplateInfo.plist of com.borealkiss.windowBasedApplication. You can add whatever files you want as long as you do the following edits. For example, if you want add a given file called <strong>SomeClass.m</strong>, you add the following two parts into the TemplateInfo.plist of com.borealkiss.windowBasedApplication:</p>
<p>These are the definition part of the file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Definitions<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Path<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>and its actual implementation:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Nodes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>If you want to add the file but not for the target of <em>Copy Bundle Resources</em> (like Info.plist, Prefix.pch, and header files), change the definition as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Definitions<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Path<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>TargetIndices<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;array</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>You can add it inside a given folder. For example if you want to add the file inside a directory called <strong>MyClasses</strong>, change the definition as follows (note that the key name should be consistent with the actual file path, otherwise the file location in the project will be different from that seen in the Finder&#8217;s view):</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Definitions<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>MyClasses/SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Group<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>MyClasses<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Path<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>MyClasses/SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Nodes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>MyClasses/SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h3>[Update on 06.04.2011]</h3>
<p>Some reader gave me a tip how to add files in a subgroup (i.e., the group inside a group). As an example consider the following situation; you are adding the SomeClass.m file that is in the location below and wanting to add it in the same directory.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">Classes/SomeClass/SomeClass.m</pre></div></div>

<p>In this case you can do this by changing a definition part:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Definitions<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Classes/SomeClass/SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Group<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Classes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SomeClass<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Path<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Classes/SomeClass/SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>and its nodes part:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Nodes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Classes/SomeClass/SomeClass.m<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>I also added these examples on my templates (link listed at the bottom).</p>
<h1>Caution before editing</h1>
<p>Keep in mind that TemplateInfo.plist is a setup file for Xcode 4 and any invalid manipulation would cause unexpected actions. For example, the following figure shows a normal behaviour of Xcode 4 during a new project creation, showing a product name and company identifier input (other options such as unit testing are disabled). And pushing the next button asks you which directory to create the project (as expected).</p>
<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/normal-behaviour.png" alt="Normal behaviour of Xcode 4" title="Normal behaviour of Xcode 4" width="500" height="340" class="aligncenter size-full wp-image-410" /></p>
<p>The following wizard pane is abnormal one after some ill manipulation. No product name input is found. Fortunately you cannot go further by pushing the next button.</p>
<p><img src="http://blog.boreal-kiss.net/wp/wp-content/uploads/2011/03/abnormal-behaviour.png" alt="Abnormal behaviour of Xcode 4" title="Abnormal behaviour of Xcode 4" width="500" height="340" class="aligncenter size-full wp-image-412" /></p>
<p>However the worst case happens when you could go further. Even if you meet the situation, do NOT push the next button; Xcode 4 creates a project inside the directory you intend to place the project. For example the directory you are placing your project folder is Desktop, Desktop will become the project folder and other irrelevant files will be gone. I had two times desktop-sweeping during the try-and-error manipulation. Be careful.</p>
<h1>Downloads</h1>
<ul>
<li><a href="https://github.com/borealkiss/Minimal-Template">https://github.com/borealkiss/Minimal-Template</a></li>
</ul>
<h1>License</h1>
<p>This template is provided under the terms of <a href="http://www.opensource.org/licenses/mit-license.php">the MIT license</a> for the reason above, i.e., feel free to use it but at your own risk.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/03/11/a-minimal-project-template-for-xcode-4/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/03/11/a-minimal-project-template-for-xcode-4/</feedburner:origLink></item>
		<item>
		<title>Moiré dots</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/GT_jaMugIJY/</link>
		<comments>http://blog.boreal-kiss.net/2011/02/moire-dots/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 17:24:12 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Graphics]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=345</guid>
		<description><![CDATA[Imagine there is an image that contains dots randomly distributing. When the image rotates around a given point in the image by small angle and the rotated image is superimposed on the original one, this makes a Moiré pattern that is perceptible to human eyes. In the video, random 1000 dots and their rotated ones [...]]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/19889025?title=0&amp;byline=0&amp;portrait=0" width="320" height="320" frameborder="0"></iframe></p>
<p>Imagine there is an image that contains dots randomly distributing. When the image rotates around a given point in the image by small angle and the rotated image is superimposed on the original one, this makes a <a href="http://en.wikipedia.org/wiki/Moir%C3%A9_pattern">Moiré pattern</a> that is perceptible to human eyes.</p>
<p>In the video, random 1000 dots and their rotated ones (rotated around the center of the screen) are simultaneously drawn in each frame. You can see some circular and/or spiral patterns in the dots storm.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/02/moire-dots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/02/moire-dots/</feedburner:origLink></item>
		<item>
		<title>Butterfly Curves</title>
		<link>http://feedproxy.google.com/~r/bbknet/~3/gPH88ZGfxc8/</link>
		<comments>http://blog.boreal-kiss.net/2011/01/butterfly-curves/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 20:25:14 +0000</pubDate>
		<dc:creator>borealkiss</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://blog.boreal-kiss.net/?p=336</guid>
		<description><![CDATA[This is one of the reasons why mathematics is so beautiful. The equations from Butterfly curve (transcendental). The drawing was performed on the iPhone simulator because I am an iPhone app developer.]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/19324837?title=0&amp;byline=0&amp;portrait=0" width="320" height="480" frameborder="0"></iframe></p>
<p>This is one of the reasons why mathematics is so beautiful. The equations from <a href="http://en.wikipedia.org/wiki/Butterfly_curve_%28transcendental%29">Butterfly curve (transcendental)</a>. The drawing was performed on the iPhone simulator because I am an iPhone app developer.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boreal-kiss.net/2011/01/butterfly-curves/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.boreal-kiss.net/2011/01/butterfly-curves/</feedburner:origLink></item>
	</channel>
</rss>

