<?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>Sorted Bits &#187; Apple</title>
	<atom:link href="http://www.sortedbits.com/category/apple/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sortedbits.com</link>
	<description>objectiveC, C# and more interesting stuff</description>
	<lastBuildDate>Wed, 04 Jan 2012 10:11:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Some useful Mac OSX tools</title>
		<link>http://www.sortedbits.com/some-useful-mac-osx-tools/</link>
		<comments>http://www.sortedbits.com/some-useful-mac-osx-tools/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 07:00:28 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>

		<guid isPermaLink="false">http://www.wim.me/?p=1339</guid>
		<description><![CDATA[Cocoa JSON Editor A very nice tool for developers, which allows you to import/paste Json and easily edit it and export an object model which can be used in Xcode. $2.99 Link Dockview DockView adds an Aero Peek (Windows 7) functionality to your OSX dock. When you [...]]]></description>
			<content:encoded><![CDATA[<table class="software-table">
<tbody>
<tr>
<td valign="top" width="200"><strong>Cocoa JSON Editor</strong></td>
<td valign="top">A very nice tool for developers, which allows you to import/paste Json and easily edit it and export an object model which can be used in Xcode.</td>
<td style="text-align: center;" valign="top" width="50">$2.99</td>
<td style="text-align: center;" valign="top" width="50"><a href="http://itunes.apple.com/nl/app/cocoa-json-editor/id442160773?mt=12">Link</a></td>
</tr>
<tr>
<td valign="top" width="200"><strong>Dockview</strong></td>
<td valign="top">DockView adds an Aero Peek (Windows 7) functionality to your OSX dock. When you hover your mouse over your dock, you will see how many windows an application has open and you can select exactly which window you want to open, by clicking on the preview window.</td>
<td style="text-align: center;" valign="top" width="50">$7.99</td>
<td style="text-align: center;" valign="top" width="50"><a href="http://kapeli.com/dockview/">Link</a></td>
</tr>
<tr>
<td valign="top" width="200"><strong>NameChanger</strong></td>
<td valign="top">A very nice tool for renaming batches of files.</td>
<td style="text-align: center;" valign="top" width="50">free</td>
<td style="text-align: center;" valign="top" width="50"><a href="http://www.mrrsoftware.com/MRRSoftware/NameChanger.html">Link</a></td>
</tr>
<tr>
<td valign="top" width="200"><strong>Reeder for Mac OSX</strong></td>
<td valign="top">The best and most beautiful RSS reader for Mac OSX.</td>
<td style="text-align: center;" valign="top" width="50">$9.99</td>
<td style="text-align: center;" valign="top" width="50"><a href="http://reederapp.com/mac/index">Link</a></td>
</tr>
<tr>
<td valign="top" width="200"><strong>Sparrow</strong></td>
<td valign="top">Superb simple mail app</td>
<td style="text-align: center;" valign="top" width="50">$9.99</td>
<td style="text-align: center;" valign="top" width="50"><a href="http://sparrowmailapp.com/">Link</a></td>
</tr>
<tr>
<td valign="top" width="200"><strong>TotalFinder</strong></td>
<td valign="top">TotalFinder extends the normal Finder. It adds tabs and other very handy options to your Finder.</td>
<td style="text-align: center;" valign="top" width="50">$15</td>
<td style="text-align: center;" valign="top" width="50"><a href="http://totalfinder.binaryage.com/">Link</a></td>
</tr>
<tr>
<td valign="top" width="200"><strong>Transmit</strong></td>
<td valign="top">Best OSX FTP client ever!</td>
<td style="text-align: center;" valign="top" width="50">$34</td>
<td style="text-align: center;" valign="top" width="50"><a href="http://panic.com/transmit">Link</a></td>
</tr>
<tr>
<td valign="top" width="200"><strong>Versions</strong></td>
<td valign="top">Superb tool for when you work with GitHub or any other Git versioning system.</td>
<td style="text-align: center;" valign="top" width="50">$39</td>
<td style="text-align: center;" valign="top" width="50"><a href="http://versionsapp.com">Link</a></td>
</tr>
</tbody>
</table>
<p>I will extend this list when I get more tools and experiences with them. If you have any tools I NEED to have, just post a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/some-useful-mac-osx-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the interface orientations from your project definition</title>
		<link>http://www.sortedbits.com/interfaceorientations/</link>
		<comments>http://www.sortedbits.com/interfaceorientations/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 06:25:35 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.wim.me/?p=1379</guid>
		<description><![CDATA[I have always been annoyed by the way you have to handle your interface orientation detection and which orientations you allow for your application. You can specify the orientations in your project&#8217;s plist file, but I am not completely sure why the UIViewControllers don&#8217;t use this by [...]]]></description>
			<content:encoded><![CDATA[<p>I have always been annoyed by the way you have to handle your interface orientation detection and which orientations you allow for your application. You can specify the orientations in your project&#8217;s plist file, but I am not completely sure why the UIViewControllers don&#8217;t use this by default.</p>
<p>So for that purpose I made a method a long time ago, which I use on most UIViewControllers, except when they allow different interface orientations then default. I use this method as a static on some class I have, which helps me do pretty default stuff.</p>
<div id="gist-1302088" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">+</span> <span class="p">(</span><span class="kt">BOOL</span><span class="p">)</span> <span class="nf">shouldAllowRotateToInterfaceOrientation:</span><span class="p">(</span><span class="n">UIInterfaceOrientation</span><span class="p">)</span> <span class="n">interfaceOrientation</span></div><div class='line' id='LC2'><span class="p">{</span></div><div class='line' id='LC3'>	<span class="n">NSString</span><span class="o">*</span> <span class="n">currentOrientation</span> <span class="o">=</span> <span class="s">@&quot;&quot;</span><span class="p">;</span></div><div class='line' id='LC4'>	<span class="k">switch</span> <span class="p">(</span><span class="n">interfaceOrientation</span><span class="p">)</span></div><div class='line' id='LC5'>	<span class="p">{</span></div><div class='line' id='LC6'>		<span class="k">case</span> <span class="nl">UIInterfaceOrientationLandscapeLeft:</span></div><div class='line' id='LC7'>			<span class="n">currentOrientation</span> <span class="o">=</span> <span class="s">@&quot;UIInterfaceOrientationLandscapeLeft&quot;</span><span class="p">;</span></div><div class='line' id='LC8'>			<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC9'>		<span class="k">case</span> <span class="nl">UIInterfaceOrientationLandscapeRight:</span></div><div class='line' id='LC10'>			<span class="n">currentOrientation</span> <span class="o">=</span> <span class="s">@&quot;UIInterfaceOrientationLandscapeRight&quot;</span><span class="p">;</span></div><div class='line' id='LC11'>			<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC12'>		<span class="k">case</span> <span class="nl">UIInterfaceOrientationPortrait:</span></div><div class='line' id='LC13'>			<span class="n">currentOrientation</span> <span class="o">=</span> <span class="s">@&quot;UIInterfaceOrientationPortrait&quot;</span><span class="p">;</span></div><div class='line' id='LC14'>			<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC15'>		<span class="k">case</span> <span class="nl">UIInterfaceOrientationPortraitUpsideDown:</span></div><div class='line' id='LC16'>			<span class="n">currentOrientation</span> <span class="o">=</span> <span class="s">@&quot;UIInterfaceOrientationPortraitUpsideDown&quot;</span><span class="p">;</span></div><div class='line' id='LC17'>			<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC18'>	<span class="p">}</span></div><div class='line' id='LC19'><br/></div><div class='line' id='LC20'>	<span class="n">NSString</span><span class="o">*</span> <span class="n">supportedOrientationsKey</span> <span class="o">=</span> <span class="s">@&quot;UISupportedInterfaceOrientations&quot;</span><span class="p">;</span></div><div class='line' id='LC21'>	<span class="k">if</span><span class="p">([</span><span class="n">UIDevice</span> <span class="n">currentDevice</span><span class="p">].</span><span class="n">userInterfaceIdiom</span> <span class="o">==</span> <span class="n">UIUserInterfaceIdiomPad</span><span class="p">)</span></div><div class='line' id='LC22'>		<span class="n">supportedOrientationsKey</span> <span class="o">=</span> <span class="s">@&quot;UISupportedInterfaceOrientations~ipad&quot;</span><span class="p">;</span></div><div class='line' id='LC23'><br/></div><div class='line' id='LC24'>	<span class="n">NSArray</span><span class="o">*</span> <span class="n">allowedOrientations</span> <span class="o">=</span> <span class="p">[[[</span><span class="n">NSBundle</span> <span class="n">mainBundle</span><span class="p">]</span> <span class="n">infoDictionary</span><span class="p">]</span> <span class="nl">objectForKey:</span><span class="n">supportedOrientationsKey</span><span class="p">];</span></div><div class='line' id='LC25'>	<span class="k">for</span> <span class="p">(</span><span class="n">NSString</span><span class="o">*</span> <span class="n">allowedOrientation</span> <span class="k">in</span> <span class="n">allowedOrientations</span><span class="p">)</span></div><div class='line' id='LC26'>	<span class="p">{</span></div><div class='line' id='LC27'>		<span class="k">if</span> <span class="p">([</span><span class="n">allowedOrientation</span> <span class="nl">isEqualToString:</span><span class="n">currentOrientation</span><span class="p">])</span></div><div class='line' id='LC28'>			<span class="k">return</span> <span class="n">YES</span><span class="p">;</span></div><div class='line' id='LC29'>	<span class="p">}</span></div><div class='line' id='LC30'><br/></div><div class='line' id='LC31'>	<span class="k">return</span> <span class="n">NO</span><span class="p">;</span></div><div class='line' id='LC32'><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1302088/6e24eb511bcfab7ef6636aa8856d6e00180ed666/gistfile1.m" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1302088#file_gistfile1.m" style="float:right;margin-right:10px;color:#666">gistfile1.m</a>
            <a href="https://gist.github.com/1302088">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>And you can just use it like this:</p>
<div id="gist-1302091" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">-</span> <span class="p">(</span><span class="kt">BOOL</span><span class="p">)</span><span class="nf">shouldAutorotateToInterfaceOrientation:</span><span class="p">(</span><span class="n">UIInterfaceOrientation</span><span class="p">)</span><span class="nv">interfaceOrientation</span></div><div class='line' id='LC2'><span class="p">{</span></div><div class='line' id='LC3'>	<span class="k">return</span> <span class="p">[</span><span class="n">WHUtilities</span> <span class="nl">shouldAllowRotateToInterfaceOrientation:</span><span class="n">interfaceOrientation</span><span class="p">];</span></div><div class='line' id='LC4'><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1302091/61be6b27c4da8765646ea41f812308ae2854e425/gistfile1.m" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1302091#file_gistfile1.m" style="float:right;margin-right:10px;color:#666">gistfile1.m</a>
            <a href="https://gist.github.com/1302091">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/interfaceorientations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protected: Localize your UIViews (the easy way)</title>
		<link>http://www.sortedbits.com/localize-your-uiviews-the-easy-way/</link>
		<comments>http://www.sortedbits.com/localize-your-uiviews-the-easy-way/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 13:21:35 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[cocoa-touch]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://www.wim.me/?p=1357</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.]]></description>
			<content:encoded><![CDATA[<form action="http://www.sortedbits.com/wp-pass.php" method="post">
<p>This post is password protected. To view it please enter your password below:</p>
<p><label for="pwbox-1357">Password:<br />
<input name="post_password" id="pwbox-1357" type="password" size="20" /></label><br />
<input type="submit" name="Submit" value="Submit" /></p></form>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/localize-your-uiviews-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using NSLog only in a DEBUG version</title>
		<link>http://www.sortedbits.com/using-nslog-only-in-a-debug-version/</link>
		<comments>http://www.sortedbits.com/using-nslog-only-in-a-debug-version/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 06:59:05 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[nslog]]></category>
		<category><![CDATA[objectivec]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://www.wim.me/?p=1289</guid>
		<description><![CDATA[I have been using this in a couple of projects. It is a method to only perform NSLog logging when you are using a DEBUG build. There are more than enough reasons why you don&#8217;t want to use NSLog in your release builds. First of all, its [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using this in a couple of projects. It is a method to only perform NSLog logging when you are using a DEBUG build. There are more than enough reasons why you don&#8217;t want to use NSLog in your release builds.</p>
<p>First of all, its all about performance. I noticed that when you use NSLog a lot it decreases performance significantly. Ofcourse you can solve this in more ways, but I found this the easiest one.</p>
<p><span id="more-1289"></span></p>
<h3>Setting the Preprocessor Macro</h3>
<p>First you need to set a <strong>Preprocessor macro</strong> for your debug build. You can do this by double clicking on your target application. The <strong>Target Info</strong> window will popup and you need to make sure that you choose the <strong>Debug</strong> configuration.</p>
<p>The just perform a search in that window for <strong>Preprocessor Macros</strong>. Once you found that, make sure you add the value <strong>DEBUG=1</strong>.</p>
<h3>Adding some code</h3>
<p>Now we are going to add some code to your applications <strong>prefix file</strong>. Just look through your applications&#8217; sources for a file called something like <strong>YourApplication_Prefix.pch</strong>. Once you find that, open up that file and use the following code:</p>
<pre class="syntax c">
#ifdef DEBUG
    #define NSLog(format, ...) NSLog(format, ## __VA_ARGS__)
#else
    #define NSLog(format, ...)
#endif
</pre>
<p>This code overrides the normal NSLog functionality. And as you can see it will only execute a real NSLog when DEBUG is not set (so, your release build).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/using-nslog-only-in-a-debug-version/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Placing curved text on an UIImage</title>
		<link>http://www.sortedbits.com/placing-curved-text-on-an-uiimage/</link>
		<comments>http://www.sortedbits.com/placing-curved-text-on-an-uiimage/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 10:26:51 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[circle]]></category>
		<category><![CDATA[cocoa-touch]]></category>
		<category><![CDATA[curve]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objectivec]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.wimhaanstra.com/?p=1210</guid>
		<description><![CDATA[For a project I am doing for a client, I needed to layout text around a circle in objective-C. I spend a couple of hours searching the internet for this, but somehow when people succeed in doing this, they don&#8217;t post their solution online. So, I made [...]]]></description>
			<content:encoded><![CDATA[<p>For a project I am doing for a client, I needed to layout text around a circle in objective-C. I spend a couple of hours searching the internet for this, but somehow when people succeed in doing this, they don&#8217;t post their solution online.</p>
<p>So, I made an array of NSString objects that I wanted to lay out, around that circle.</p>
<div id="gist-1302242" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="n">NSArray</span><span class="o">*</span> <span class="n">sections</span> <span class="o">=</span> <span class="p">[[</span><span class="n">NSArray</span> <span class="n">alloc</span><span class="p">]</span> <span class="nl">initWithObjects:</span><span class="s">@&quot;text1&quot;</span><span class="p">,</span> <span class="s">@&quot;text2&quot;</span><span class="p">,</span> <span class="s">@&quot;text3&quot;</span><span class="p">,</span> <span class="s">@&quot;text4&quot;</span><span class="p">,</span> <span class="nb">nil</span><span class="p">];</span></div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'><span class="k">-</span> <span class="p">(</span><span class="n">UIImage</span><span class="o">*</span><span class="p">)</span> <span class="nf">createMenuRingWithFrame:</span><span class="p">(</span><span class="n">CGRect</span><span class="p">)</span><span class="nv">frame</span></div><div class='line' id='LC4'><span class="p">{</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// First fix the frame to make sure it uses the right scaling (iPhone 4 / iPad compatibility).</span></div><div class='line' id='LC6'>	<span class="n">frame</span> <span class="o">=</span> <span class="n">CGRectMake</span><span class="p">(</span><span class="n">frame</span><span class="p">.</span><span class="n">origin</span><span class="p">.</span><span class="n">x</span><span class="p">,</span> <span class="n">frame</span><span class="p">.</span><span class="n">origin</span><span class="p">.</span><span class="n">y</span><span class="p">,</span> <span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">width</span> <span class="o">*</span> <span class="n">scale</span><span class="p">,</span> <span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">height</span> <span class="o">*</span> <span class="n">scale</span><span class="p">);</span></div><div class='line' id='LC7'><br/></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// Same for the text radius</span></div><div class='line' id='LC9'>	<span class="kt">float</span> <span class="n">scaledTextRadius</span> <span class="o">=</span> <span class="n">textRadius</span> <span class="o">*</span> <span class="n">scale</span><span class="p">;</span></div><div class='line' id='LC10'>	<span class="kt">float</span> <span class="n">scaledRingWidth</span> <span class="o">=</span> <span class="n">ringWidth</span><span class="p">;</span></div><div class='line' id='LC11'><br/></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// Define the centerpoint of the circle.</span></div><div class='line' id='LC13'>	<span class="n">CGPoint</span> <span class="n">centerPoint</span> <span class="o">=</span> <span class="n">CGPointMake</span><span class="p">(</span><span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">width</span> <span class="o">/</span> <span class="mi">2</span><span class="p">,</span> <span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">height</span> <span class="o">/</span> <span class="mi">2</span><span class="p">);</span></div><div class='line' id='LC14'><br/></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// self.menuItemsFont is of the type UIFont, which I use to get the font for displaying the text on the circle.</span></div><div class='line' id='LC16'>	<span class="kt">char</span><span class="o">*</span> <span class="n">fontName</span> <span class="o">=</span> <span class="p">(</span><span class="kt">char</span><span class="o">*</span><span class="p">)[</span><span class="n">self</span><span class="p">.</span><span class="n">menuItemsFont</span><span class="p">.</span><span class="n">fontName</span> <span class="nl">cStringUsingEncoding:</span><span class="n">NSASCIIStringEncoding</span><span class="p">];</span></div><div class='line' id='LC17'><br/></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// 2 UIColor&#39;s, which I need for the color of the circle and for the text</span></div><div class='line' id='LC19'>	<span class="n">ringColor</span> <span class="o">=</span> <span class="p">[</span><span class="n">UIColor</span> <span class="nl">colorWithRed:</span><span class="mi">1</span> <span class="nl">green:</span><span class="mi">1</span> <span class="nl">blue:</span><span class="mi">1</span> <span class="nl">alpha:</span><span class="mf">0.7</span><span class="p">];</span></div><div class='line' id='LC20'>	<span class="n">textColor</span> <span class="o">=</span> <span class="p">[</span><span class="n">UIColor</span> <span class="nl">colorWithRed:</span><span class="mi">0</span> <span class="nl">green:</span><span class="mi">0</span> <span class="nl">blue:</span><span class="mi">0</span> <span class="nl">alpha:</span><span class="mi">1</span><span class="p">];</span></div><div class='line' id='LC21'><br/></div><div class='line' id='LC22'>	<span class="n">CGFloat</span><span class="o">*</span> <span class="n">ringColorComponents</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float</span><span class="o">*</span><span class="p">)</span><span class="n">CGColorGetComponents</span><span class="p">(</span><span class="n">ringColor</span><span class="p">.</span><span class="n">CGColor</span><span class="p">);</span></div><div class='line' id='LC23'>	<span class="n">CGFloat</span><span class="o">*</span> <span class="n">textColorComponents</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float</span><span class="o">*</span><span class="p">)</span><span class="n">CGColorGetComponents</span><span class="p">(</span><span class="n">textColor</span><span class="p">.</span><span class="n">CGColor</span><span class="p">);</span></div><div class='line' id='LC24'><br/></div><div class='line' id='LC25'>	<span class="n">CGColorSpaceRef</span> <span class="n">colorSpace</span> <span class="o">=</span> <span class="n">CGColorSpaceCreateDeviceRGB</span><span class="p">();</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">CGContextRef</span> <span class="n">context</span> <span class="o">=</span> <span class="n">CGBitmapContextCreate</span><span class="p">(</span><span class="nb">NULL</span><span class="p">,</span> <span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">width</span><span class="p">,</span> <span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">height</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">4</span> <span class="o">*</span> <span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">width</span><span class="p">,</span> <span class="n">colorSpace</span><span class="p">,</span> <span class="n">kCGImageAlphaPremultipliedFirst</span><span class="p">);</span></div><div class='line' id='LC27'><br/></div><div class='line' id='LC28'>	<span class="n">CGContextSetTextMatrix</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">CGAffineTransformIdentity</span><span class="p">);</span></div><div class='line' id='LC29'><br/></div><div class='line' id='LC30'>	<span class="n">CGContextSelectFont</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">fontName</span><span class="p">,</span> <span class="mi">18</span> <span class="o">*</span> <span class="n">scale</span><span class="p">,</span> <span class="n">kCGEncodingMacRoman</span><span class="p">);</span></div><div class='line' id='LC31'>	<span class="n">CGContextSetRGBStrokeColor</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">ringColorComponents</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">ringColorComponents</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">ringColorComponents</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">ringAlpha</span><span class="p">);</span></div><div class='line' id='LC32'>	<span class="n">CGContextSetLineWidth</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">scaledRingWidth</span><span class="p">);</span></div><div class='line' id='LC33'><br/></div><div class='line' id='LC34'>	<span class="n">CGContextStrokeEllipseInRect</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">CGRectMake</span><span class="p">(</span><span class="n">scaledRingWidth</span><span class="p">,</span> <span class="n">scaledRingWidth</span><span class="p">,</span> <span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">width</span> <span class="o">-</span> <span class="p">(</span><span class="n">scaledRingWidth</span> <span class="o">*</span> <span class="mi">2</span><span class="p">),</span> <span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">height</span> <span class="o">-</span> <span class="p">(</span><span class="n">scaledRingWidth</span> <span class="o">*</span> <span class="mi">2</span><span class="p">)));</span></div><div class='line' id='LC35'>	<span class="n">CGContextSetRGBFillColor</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">textColorComponents</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">textColorComponents</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">textColorComponents</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">textAlpha</span><span class="p">);</span></div><div class='line' id='LC36'><br/></div><div class='line' id='LC37'>	<span class="n">CGContextSaveGState</span><span class="p">(</span><span class="n">context</span><span class="p">);</span></div><div class='line' id='LC38'>	<span class="n">CGContextTranslateCTM</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">centerPoint</span><span class="p">.</span><span class="n">x</span><span class="p">,</span> <span class="n">centerPoint</span><span class="p">.</span><span class="n">y</span><span class="p">);</span></div><div class='line' id='LC39'><br/></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// define the angles of the texts to divide them evenly on the circle.</span></div><div class='line' id='LC41'>	<span class="kt">float</span> <span class="n">angleStep</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">M_PI</span> <span class="o">/</span> <span class="p">[</span><span class="n">sections</span> <span class="n">count</span><span class="p">];</span></div><div class='line' id='LC42'><br/></div><div class='line' id='LC43'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// I set the starting-angle on 90 degrees, to make sure the first text was ON TOP of the circle.</span></div><div class='line' id='LC44'>	<span class="kt">float</span> <span class="n">angle</span> <span class="o">=</span> <span class="n">degreesToRadians</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span></div><div class='line' id='LC45'><br/></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// Some custom text-radius fixing (and scaling for iPhone 4 &amp;amp; iPad). To make sure my text centered nicely.</span></div><div class='line' id='LC47'>	<span class="n">scaledTextRadius</span> <span class="o">=</span> <span class="n">scaledTextRadius</span> <span class="o">-</span> <span class="mi">12</span> <span class="o">*</span> <span class="n">scale</span><span class="p">;</span></div><div class='line' id='LC48'><br/></div><div class='line' id='LC49'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// Loop through texts and draw them at the appropriate angle.</span></div><div class='line' id='LC50'>	<span class="k">for</span> <span class="p">(</span><span class="n">NSString</span><span class="o">*</span> <span class="n">text</span> <span class="k">in</span> <span class="n">sections</span><span class="p">)</span></div><div class='line' id='LC51'>	<span class="p">{</span></div><div class='line' id='LC52'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// call a method that actually draws the text at an angle</span></div><div class='line' id='LC53'>		<span class="p">[</span><span class="n">self</span> <span class="nl">drawStringAtContext:</span><span class="n">context</span> <span class="nl">string:</span><span class="n">text</span> <span class="nl">atAngle:</span><span class="n">angle</span> <span class="nl">withRadius:</span><span class="n">scaledTextRadius</span><span class="p">];</span></div><div class='line' id='LC54'>		<span class="n">angle</span> <span class="o">-=</span> <span class="n">angleStep</span><span class="p">;</span></div><div class='line' id='LC55'>	<span class="p">}</span></div><div class='line' id='LC56'><br/></div><div class='line' id='LC57'>	<span class="n">CGContextRestoreGState</span><span class="p">(</span><span class="n">context</span><span class="p">);</span></div><div class='line' id='LC58'><br/></div><div class='line' id='LC59'>	<span class="n">CGImageRef</span> <span class="n">contextImage</span> <span class="o">=</span> <span class="n">CGBitmapContextCreateImage</span><span class="p">(</span><span class="n">context</span><span class="p">);</span></div><div class='line' id='LC60'><br/></div><div class='line' id='LC61'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// Release the stuff to avoid memory leaks.</span></div><div class='line' id='LC62'>	<span class="n">CGContextRelease</span><span class="p">(</span><span class="n">context</span><span class="p">);</span></div><div class='line' id='LC63'>	<span class="n">CGColorSpaceRelease</span><span class="p">(</span><span class="n">colorSpace</span><span class="p">);</span></div><div class='line' id='LC64'><br/></div><div class='line' id='LC65'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="p">[</span><span class="n">UIImage</span> <span class="nl">imageWithCGImage:</span><span class="n">contextImage</span><span class="p">];</span></div><div class='line' id='LC66'><br/></div><div class='line' id='LC67'><span class="p">}</span></div><div class='line' id='LC68'><br/></div><div class='line' id='LC69'><span class="c1">// This method draws the text at an angle, while the location is based on the radius + angle.</span></div><div class='line' id='LC70'><span class="k">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="nf">drawStringAtContext:</span><span class="p">(</span><span class="n">CGContextRef</span><span class="p">)</span> <span class="n">context</span> <span class="nl">string:</span><span class="p">(</span><span class="n">NSString</span><span class="o">*</span><span class="p">)</span> <span class="n">text</span> <span class="nl">atAngle:</span><span class="p">(</span><span class="kt">float</span><span class="p">)</span> <span class="n">angle</span> <span class="nl">withRadius:</span><span class="p">(</span><span class="kt">float</span><span class="p">)</span> <span class="n">radius</span></div><div class='line' id='LC71'><span class="p">{</span></div><div class='line' id='LC72'>	<span class="c1">// Scale the fontsize to match UIScreen scaling</span></div><div class='line' id='LC73'>	<span class="n">UIFont</span><span class="o">*</span> <span class="n">scaledMenuItemsFont</span> <span class="o">=</span> <span class="p">[</span><span class="n">menuItemsFont</span> <span class="nl">fontWithSize:</span><span class="mi">18</span> <span class="o">*</span> <span class="n">scale</span><span class="p">];</span></div><div class='line' id='LC74'><br/></div><div class='line' id='LC75'>	<span class="c1">// Get the size of the string when it would be drawn with the selected font</span></div><div class='line' id='LC76'>	<span class="n">CGSize</span> <span class="n">textSize</span> <span class="o">=</span> <span class="p">[</span><span class="n">text</span> <span class="nl">sizeWithFont:</span><span class="n">scaledMenuItemsFont</span><span class="p">];</span></div><div class='line' id='LC77'><br/></div><div class='line' id='LC78'>	<span class="kt">float</span> <span class="n">perimeter</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">M_PI</span> <span class="o">*</span> <span class="n">radius</span><span class="p">;</span></div><div class='line' id='LC79'><br/></div><div class='line' id='LC80'>	<span class="c1">// determine the angle of the text.</span></div><div class='line' id='LC81'>	<span class="kt">float</span> <span class="n">textAngle</span> <span class="o">=</span> <span class="p">(</span><span class="n">textSize</span><span class="p">.</span><span class="n">width</span><span class="p">)</span> <span class="o">/</span> <span class="n">perimeter</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">M_PI</span><span class="p">;</span></div><div class='line' id='LC82'>	<span class="n">angle</span> <span class="o">+=</span> <span class="n">textAngle</span> <span class="o">/</span> <span class="mi">2</span><span class="p">;</span></div><div class='line' id='LC83'><br/></div><div class='line' id='LC84'>	<span class="c1">// We loop through each letter in the string, so we can set the angle for each letter right</span></div><div class='line' id='LC85'>	<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">index</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">index</span> <span class="o">&amp;</span><span class="n">lt</span><span class="p">;</span> <span class="p">[</span><span class="n">text</span> <span class="n">length</span><span class="p">];</span> <span class="n">index</span><span class="o">++</span><span class="p">)</span></div><div class='line' id='LC86'>	<span class="p">{</span></div><div class='line' id='LC87'>	    <span class="c1">// Get the correct letter by the index</span></div><div class='line' id='LC88'>		<span class="n">NSRange</span> <span class="n">range</span> <span class="o">=</span> <span class="p">{</span><span class="n">index</span><span class="p">,</span> <span class="mi">1</span><span class="p">};</span></div><div class='line' id='LC89'>		<span class="n">NSString</span><span class="o">*</span> <span class="n">letter</span> <span class="o">=</span> <span class="p">[</span><span class="n">text</span> <span class="nl">substringWithRange:</span><span class="n">range</span><span class="p">];</span></div><div class='line' id='LC90'>		<span class="kt">char</span><span class="o">*</span> <span class="n">c</span> <span class="o">=</span> <span class="p">(</span><span class="kt">char</span><span class="o">*</span><span class="p">)[</span><span class="n">letter</span> <span class="nl">cStringUsingEncoding:</span><span class="n">NSASCIIStringEncoding</span><span class="p">];</span></div><div class='line' id='LC91'>		<span class="n">CGSize</span> <span class="n">charSize</span> <span class="o">=</span> <span class="p">[</span><span class="n">letter</span> <span class="nl">sizeWithFont:</span><span class="n">scaledMenuItemsFont</span><span class="p">];</span></div><div class='line' id='LC92'><br/></div><div class='line' id='LC93'>	    <span class="c1">// Determin the X and Y position of the letter based on the angle and the radius</span></div><div class='line' id='LC94'>		<span class="kt">float</span> <span class="n">x</span> <span class="o">=</span> <span class="n">radius</span> <span class="o">*</span> <span class="n">cos</span><span class="p">(</span><span class="n">angle</span><span class="p">);</span></div><div class='line' id='LC95'>		<span class="kt">float</span> <span class="n">y</span> <span class="o">=</span> <span class="n">radius</span> <span class="o">*</span> <span class="n">sin</span><span class="p">(</span><span class="n">angle</span><span class="p">);</span></div><div class='line' id='LC96'><br/></div><div class='line' id='LC97'>		<span class="kt">float</span> <span class="n">letterAngle</span> <span class="o">=</span> <span class="p">(</span><span class="n">charSize</span><span class="p">.</span><span class="n">width</span> <span class="o">/</span> <span class="n">perimeter</span> <span class="o">*</span> <span class="o">-</span><span class="mi">2</span> <span class="o">*</span> <span class="n">M_PI</span><span class="p">);</span></div><div class='line' id='LC98'><br/></div><div class='line' id='LC99'>	    <span class="c1">// Save the state of the context, because rotations are based on the original origin</span></div><div class='line' id='LC100'>		<span class="n">CGContextSaveGState</span><span class="p">(</span><span class="n">context</span><span class="p">);</span></div><div class='line' id='LC101'>		<span class="n">CGContextTranslateCTM</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">);</span></div><div class='line' id='LC102'>	    <span class="c1">// Rotate the canvas so we can just draw our text horizontally</span></div><div class='line' id='LC103'>		<span class="n">CGContextRotateCTM</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="p">(</span><span class="n">angle</span> <span class="o">-</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">M_PI</span><span class="p">));</span></div><div class='line' id='LC104'>		<span class="n">CGContextShowTextAtPoint</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">strlen</span><span class="p">(</span><span class="n">c</span><span class="p">));</span></div><div class='line' id='LC105'>	    <span class="c1">// Restore the context again.</span></div><div class='line' id='LC106'>		<span class="n">CGContextRestoreGState</span><span class="p">(</span><span class="n">context</span><span class="p">);</span></div><div class='line' id='LC107'><br/></div><div class='line' id='LC108'>		<span class="n">angle</span> <span class="o">+=</span> <span class="n">letterAngle</span><span class="p">;</span></div><div class='line' id='LC109'>	<span class="p">}</span></div><div class='line' id='LC110'><span class="p">}</span></div><div class='line' id='LC111'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1302242/0d62efc44eb7d0b2219731bc7a424fd41d4e3103/gistfile1.m" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1302242#file_gistfile1.m" style="float:right;margin-right:10px;color:#666">gistfile1.m</a>
            <a href="https://gist.github.com/1302242">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>I came to this solution after I asked a question on StackOverflow, which was helpfully demonstrated by Dribbel on how to do it. Credits for that to him.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/placing-curved-text-on-an-uiimage/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Putting a UIPickerView on a UIActionSheet</title>
		<link>http://www.sortedbits.com/putting-a-uipickerview-on-a-uiactionsheet/</link>
		<comments>http://www.sortedbits.com/putting-a-uipickerview-on-a-uiactionsheet/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 20:24:50 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[uiactionsheet]]></category>
		<category><![CDATA[uipickerview]]></category>

		<guid isPermaLink="false">http://www.wimhaanstra.com/?p=1002</guid>
		<description><![CDATA[Basically there are no really good (and now working) guides on how to put a UIPickerView on a UIActionSheet. Mainly because some things changed with the latest firmware updates made by Apple. Well after some fiddling around, I got it working. Here is how: Step 1: Adding [...]]]></description>
			<content:encoded><![CDATA[<p>Basically there are no really good (and now working) guides on how to put a UIPickerView on a UIActionSheet. Mainly because some things changed with the latest firmware updates made by Apple. Well after some fiddling around, I got it working. Here is how:</p>
<p><strong>Step 1: Adding the right delegates</strong><br />
Make sure your current class (probably a ViewController) uses the following delegates:</p>
<ul>
<li>UIActionSheetDelegate</li>
<li>UINavigationControllerDelegate</li>
<li>UIPickerViewDelegate</li>
<li>UIPickerViewDataSource</li>
</ul>
<p><span id="more-1002"></span></p>
<p><strong>Step 2: Trigger the UIActionSheet</strong><br />
Go to the method where you want to make the UIPickerView appear. In my case it is when I select a row from a table, but of course it could also be when you push a button or anything you want.</p>
<pre class="syntax c">/* first create a UIActionSheet, where you define a title, delegate and a button to close the sheet again */
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@&quot;Select position&quot; delegate:self cancelButtonTitle:@&quot;Done&quot; destructiveButtonTitle:nil otherButtonTitles:nil];
/* I always give my controls a tag, to make sure I can work with multiple actionsheets in one View (to identify them when an event triggers */
actionSheet.tag = POSITION_ROW;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

/* Initialize a UIPickerView with 100px space above it, for the button of the UIActionSheet. */
UIPickerView* positionPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,100, 320, 216)];
positionPicker.dataSource = self;
positionPicker.delegate = self;

/* another unique tag for this UIPicker */
positionPicker.tag = POSITION_ROW;

/* Add the UIPickerView to the UIActionSheet */
[actionSheet addSubview:positionPicker];

/* Select the previous selected value, which for me is stored in 'currentPosition' */
[positionPicker selectRow:currentPosition inComponent:0 animated:NO];

/* clean up */
[positionPicker release];

/* Add the UIActionSheet to the view */
[actionSheet showInView:self.view];

/* Make sure the UIActionSheet is big enough to fit your UIPickerView and it's buttons */
[actionSheet setBounds:CGRectMake(0,0, 320, 411)];

/* clean up */
[actionSheet release];</pre>
<p><strong>Step 3: Implementing the datasource and delegates for the UIPickerView</strong><br />
Now, the triggering of the UIActionSheet is now working, but you would also like to have some items in your UIPickerView. Well, take a look at the following code and read the comments.</p>
<pre class="syntax c">/* Defines the total number of Components (like groups in a UITableView) in a UIPickerView */
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
    return 1;
}

/* What to do when a row from a UIPickerView is selected. This will trigger each time you scroll the UIPickerView, so only lightweight stuff. */
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
	overlayPosition = row;
	[tableSettings reloadData];
}

/* For me the number of items in the UIPickerView is known on compile time. So here I just return 3 */
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
    return 3;
}

/* Because the UIPickerView expects a UIView for every row you insert in the UIPickerView, you need to make one. What I do here is really simple. I create a UILabel* and with each row it requests I just change the text in the UILabel. */
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
/* Create a UILabel and set it 40 pixels to the right, to make sure it is put nicely in the UIPickerView */
	UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(40, 0, 280, 25)] autorelease];
	label.textColor = [UIColor blackColor];
	label.backgroundColor = [UIColor clearColor];

	switch (row)
	{
		default:
		case kUnderClock:
			label.text = @&quot;Under clock&quot;;
			break;
		case kAboveSlider:
			label.text = @&quot;Above lock slider&quot;;
			break;
		case kCenter:
			label.text = @&quot;Vertically centered&quot;;
			break;
	}

	return label;
}</pre>
<p><strong>Step 4: Do stuff when buttons on the UIActionSheet are clicked</strong><br />
Now, the final thing you have to do is make sure you listen to the events of the UIActionSheet also. So here is the code:</p>
<pre class="syntax c">- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
	if (actionSheet.tag == POSITION_ROW)
	{
/* Do stuff here, only intended for the right UIActionSheet. This only applies for when you use multiple UIActionSheets on the same ViewController. Closing it is unnecessary, because you already specified a destructive button. */
	}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/putting-a-uipickerview-on-a-uiactionsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save an UIView to an UIImage in objective-C</title>
		<link>http://www.sortedbits.com/save-an-uiview-to-an-uiimage-in-objective-c/</link>
		<comments>http://www.sortedbits.com/save-an-uiview-to-an-uiimage-in-objective-c/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 14:14:55 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[desktop backgrounds hd]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[uiimage]]></category>
		<category><![CDATA[uiview]]></category>

		<guid isPermaLink="false">http://www.wimhaanstra.com/?p=837</guid>
		<description><![CDATA[For an application I am making, I am making a view where users can configure all kinds of settings, which has direct effect on an UIView I have. I want to grab that UIView and save it as an image. Well there are examples enough about this, [...]]]></description>
			<content:encoded><![CDATA[<p>For an application I am making, I am making a view where users can configure all kinds of settings, which has direct effect on an UIView I have. I want to grab that UIView and save it as an image.</p>
<p>Well there are examples enough about this, most of them are all the same, but there is one annoying thing. It saves the view in the good ol&#8217; resolution. Because I am making all my apps &#8220;retina-aware&#8221;, I wanted to change this.</p>
<p><span id="more-850"></span>So here is my code snippet of how I save an UIView to an UIImage:</p>
<pre>UIGraphicsBeginImageContextWithOptions(myView.bounds.size, NO, [[UIScreen mainScreen] scale]);
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();</pre>
<p>It automaticly takes care of any scaling, if there will be higher resolution iPhones/iPads in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/save-an-uiview-to-an-uiimage-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mount network drive before starting an app</title>
		<link>http://www.sortedbits.com/mount-network-drive-before-starting-an-app/</link>
		<comments>http://www.sortedbits.com/mount-network-drive-before-starting-an-app/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 15:58:25 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.depl0y.com/?p=437</guid>
		<description><![CDATA[On my Mac Mini, I have SABNZBd+ installed. I wanted to make it download my usenet downloads straight to my NAS. So I made my Mac automaticly mount a drive on the NAS on boot, and I also put SABNZBd+ in my login items. But that gave [...]]]></description>
			<content:encoded><![CDATA[<p>On my Mac Mini, I have SABNZBd+ installed. I wanted to make it download my usenet downloads straight to my NAS.</p>
<p>So I made my Mac automaticly mount a drive on the NAS on boot, and I also put SABNZBd+ in  my login items. But that gave me a problem, sometimes SABNZBd started before my network drive was mounted. SABNZBd then created a directory called /Volumes/Media. After that, when my NAS was mounted, it mounted to /Volumes/Media-1. So that sucked. I could not find a way to change the order at which startup programs ran, so I decided to create an AppleScript application which first mounted a network drive and then runned SABNZBd.</p>
<p>Here it is:</p>
<pre>set Media to "smb://myUsername:myPassword@192.168.1.1/Media"
tell application "Finder"
	activate
	mount volume Media
end tell
tell application "SABnzbd"
	activate
end tell</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/mount-network-drive-before-starting-an-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replacing my HDX 1000 with a Mac Mini</title>
		<link>http://www.sortedbits.com/replacing-my-hdx-1000-with-a-mac-mini/</link>
		<comments>http://www.sortedbits.com/replacing-my-hdx-1000-with-a-mac-mini/#comments</comments>
		<pubDate>Sun, 03 May 2009 18:39:59 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>

		<guid isPermaLink="false">http://www.depl0y.com/?p=411</guid>
		<description><![CDATA[For my HD movie playback I have been using an HDX 1000 the last couple of months. The HDX is connected via an ethernet connection with my file server, which is an Intel quadcore with over 4TB of storage and 12GB of memory. Since this isn&#8217;t the [...]]]></description>
			<content:encoded><![CDATA[<p>For my HD movie playback I have been using an HDX 1000 the last couple of months. The HDX is connected via an ethernet connection with my file server, which is an Intel quadcore with over 4TB of storage and 12GB of memory. Since this isn&#8217;t the most energy efficient way to stream movies to my TV, I planned a complete reorganisation of PC equipment at home.</p>
<p>I am replacing my HDX 1000 with a Mac Mini (2.26GHz with 4GB of RAM), which will be connected to my TV with a mini-DVI to DVI to HDMI cable. The Mac Mini has an optical audio out, which will be connected to my Sony receiver, for optimal DTS/DD5.1 audio.</p>
<p>The Mac Mini will stream it&#8217;s movies from a multi TB NAS, which will be connected to a gigabit router. For software, I am currently expirimenting with XBMC, with the Aeon skin. The Mac Mini will also be connected to my 26&#8243; IIyama monitor, so that it can be used as a desktop PC too, which gives my MacBook Pro a bit more breathing room. Also the switch to a Mac Mini will give me the ability to playback those anoying DVD&#8217;s the kids bring home sometimes.</p>
<p>I already ordered my Mac Mini and it will be delivered between the 8th and 11th of May.</p>
<p>So, what problems am I going to encounter?</p>
<ul>
<li>I needed to find a mini-TOS to TOS cable, which wasn&#8217;t available in the Apple store somehow. Found one on eBay for under $5.</li>
<li>The remote control didn&#8217;t work at once with XBMC somehow. I installed a piece of software called &#8220;Sofa Control&#8221; which fixed this, but this software isn&#8217;t free.</li>
<li>I use usenet a lot, with my file server gone, I will no longer be able to use Newsleecher. What alternatives are there for Newsleecher for OSX?</li>
</ul>
<p>As soon as my Mac Mini arrives, I will post a report about my progress, maybe with some pics.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/replacing-my-hdx-1000-with-a-mac-mini/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Make Xcode behave more like Visual Studio ;)</title>
		<link>http://www.sortedbits.com/make-xcode-behave-more-like-visual-studio/</link>
		<comments>http://www.sortedbits.com/make-xcode-behave-more-like-visual-studio/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 21:01:35 +0000</pubDate>
		<dc:creator>Wim</dc:creator>
				<category><![CDATA[Apple]]></category>

		<guid isPermaLink="false">http://www.depl0y.com/?p=376</guid>
		<description><![CDATA[I am getting used to Xcode more and more, but the default behavior for double clicking files in the file tree really sucks. In the default mode it opens up an extra window, which is annoying when you are used to Visual Studio. I googled on this [...]]]></description>
			<content:encoded><![CDATA[<p>I am getting used to Xcode more and more, but the default behavior for double clicking files in the file tree really sucks. In the default mode it opens up an extra window, which is annoying when you are used to Visual Studio.</p>
<p>I googled on this a lot lately and I couldn&#8217;t find any answers, so I finally went looking through the settings of Xcode, just to see what I could tweak. Well I found it!</p>
<p>Well first, you need to close all project windows in your Xcode and then go to the Xcode preferences screen.</p>
<p><a href="http://images.depl0y.com/galleries/Xcode/Picture%201.png"><img alt="" src="http://images.depl0y.com/galleries/Xcode/Picture%201.png" class="alignnone" width="500" /></a></p>
<p>In the general tab, set the layout option to &#8220;Condensed&#8221;. After that you can open up a project and your file tree will be a undocked window. Double click one of the files in your tree, that should open up a code windows and on the code windows&#8217; right-top side should appear 2 icons like this:</p>
<p><a href="http://images.depl0y.com/galleries/Xcode/Picture%202.png"><img alt="" src="http://images.depl0y.com/galleries/Xcode/Picture%202.png" class="alignnone" width="131" height="93" /></a></p>
<p>Make sure the 2nd icon from the right says &#8220;Grouped&#8221;. If it says ungrouped just click it once to make it say &#8220;Grouped&#8221;.</p>
<p>After that, when you double click a file, it will just show you the code in the currently open code window! Hurray!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sortedbits.com/make-xcode-behave-more-like-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

