<?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>Confessions of a Swift Addict</title>
	<atom:link href="http://www.funky-monkey.nl/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.funky-monkey.nl/blog</link>
	<description>&#34;forgive me father for I have swifted&#34;</description>
	<lastBuildDate>Mon, 10 Oct 2016 09:41:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.6.1</generator>
	<item>
		<title>Swift 3 Conversion Steps. Or “The 9 steps to Swift bliss”</title>
		<link>http://www.funky-monkey.nl/blog/2016/10/swift-3-conversion-steps-or-the-9-steps-to-swift-bliss/</link>
		<comments>http://www.funky-monkey.nl/blog/2016/10/swift-3-conversion-steps-or-the-9-steps-to-swift-bliss/#respond</comments>
		<pubDate>Mon, 10 Oct 2016 09:19:33 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Swift]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1571</guid>
		<description><![CDATA[Every time Apple decided to bring out a new version of Swift, I’d dive headfirst and start the conversion — the sooner the better. None of the past versions were such a nightmare as from Swift 2.1 to 3.0. These notes I wrote down while converting our project to a Swift 3.0 project. Hopefully someone finds them [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Every time Apple decided to bring out a new version of Swift, I’d dive headfirst and start the conversion — the sooner the better. None of the past versions were such a nightmare as from Swift 2.1 to 3.0.</p>
<p>These notes I wrote down while converting our project to a Swift 3.0 project. Hopefully someone finds them useful. If you have comments or like to see something added, please let me know.</p>
<p>Let me start with a big fat warning.</p>
<p style="text-align: center;">⚠️ <strong>Don&#8217;t &#8216;Update to recommended setting&#8217;. Do this later.</strong> ⚠️</p>
<p>So the steps to undertake and achieve Swift bliss are this.</p>
<ol>
<li>Create new branch.</li>
<li>Change `Podfile` to reflect the following<code><br />
platform :ios, '9.0'<br />
use_frameworks!<br />
inhibit_all_warnings!<br />
</code></li>
<li>Update dependencies with a pod update</li>
<li>Commit changes to git</li>
<li>Convert to Swift 3 syntax</li>
<li>Commit changes</li>
<li>Fix errors (loads of them)</li>
<li>Lint</li>
<li>Commit changes</li>
</ol>
<h3>Breaking changes in Swift 3 Conversion</h3>
<p>So first things first &#8211; you are not alone in this. Apple has created a good starting point with their <a href="https://swift.org/migration-guide/">migration guide</a>. Read it before starting the conversion and keep it as a reference while converting.</p>
<ul>
<li>New <a href="http://useyourloaf.com/blog/swift-3-access-controls/">keywords</a>. It takes some getting used to. Current behavior changed too.</li>
<li>String <a href="http://www.swift-studies.com/blog/2016/6/17/swift-30-string-index-changes">indexes and Ranges</a> work different</li>
<li><code>ErrorType</code> ⇒ <code>Error</code></li>
<li>All enum cases are now lowercase</li>
<li>Use of <code>_</code> in methods to supres/omit names parameters. Named parameters are now default.</li>
<li><code>.[upper/lower]caseString</code> ⇒ <code>.[upper/lower]cased()</code> because it is mutating.</li>
<li><code>for</code> can now be used for named parameters <code>.addTarget(self, action: ..., for: ...)</code></li>
<li><code>containsString()</code> ⇒ <code>contains()</code></li>
<li><code>.objectForKey(...)</code> ⇒ <code>object(forKey: ...)</code></li>
<li>Colors are not a function call anymore but [class var](https://developer.apple.com/reference/uikit/uicolor/2091975-black)</li>
<li><code>where</code> keyword in optional binding not needed anymore, you can now just use a comma</li>
<li><code>CGColorRef</code> ⇒ <code>CGColor</code></li>
<li>when using multiple properties in single <code>guard</code> you must use <code>let</code> for each property. Also in optional binding.</li>
<li><code>UIControlState.Normal</code> ⇒ <code>UIControlState()</code></li>
<li><code>UIView.animateWithDuration</code> ⇒ <code>UIView.animate(withDuration</code></li>
<li><code>NSFetchedResultsController</code> is now a Generic and must be called with a concrete Type of the Entity you wish to fetch. Like so: <code>NSFetchedResultsController</code> Same with <code>NSFetchRequest(entityName: "Enitity")</code></li>
<li><code>String(self)</code> ⇒ <code>String(describing: self)</code></li>
<li>Dispatch Queues tend to f-up the migrator wizard syntax. It mangles it like this: <code>DispatchQueue.main.sync(DispatchQueue.mainexecute: { () -&gt; Void in</code><br />
but should have been <code>DispatchQueue.main.sync {</code><br />
<a href="http://swiftable.io/2016/06/dispatch-queues-swift-3/">Swiftable has more info on this</a></li>
</ul>
<h3><strong>Errors:</strong></h3>
<p>Q: <strong>&#8220;Argument label does not match any available overloads&#8221;</strong><br />
A: In the conversion to Swift 3 something went haywire, look in the original implenmentation wat the function signature is you want to implement.</p>
<p>Q: <strong>&#8220;Ambiguous reference&#8221;</strong><br />
A: You need to provide more Type detail. Usually this is fixed by adding an <code>: Type</code> or an <code>as? Type</code> or with an optional binding <code>if let ...</code>. When this method comes from an Objective-C external lib &#8211; what also helps is to annotate the Objective-C methods with <code>NS_SWIFT_NAME(method(arg1:arg2:))</code></p>
<p>Q: <strong>&#8220;Method cannot be declared because its parameter uses an internal type&#8221;</strong><br />
A: Take a close look at the access modifiers. The above states that there are no (and thus <code>internal</code>), or wrong access modifiers used.</p>
<p>Q: <strong>&#8220;Instance method &#8216;method(param:)&#8217; nearly matches optional requirement &#8216;method(in:)&#8217; of protocol &#8216;SomeProtocol'&#8221;</strong><br />
A: In some cases the Swift migrator fails but does find something that looks like that method signature. Usually fixable by searching and copying the orginal protocol for the method signature. In UIKit protocols is almost always the case that you need to supress the param name by adding an underscore to it. So <code>func method(param:)</code> becomes <code>func method(_ param:)</code></p>
<p>Q: <strong>&#8220;Expression of type &#8220;SomeType?&#8221; is unused&#8221;.</strong><br />
A: (<a href="http://stackoverflow.com/a/37843720">This answer comes directly from Stack Overflow</a>) Before Swift 3, all methods had a &#8220;discardable result&#8221; by default. No warning would occur when you did not capture what the method returned.</p>
<p>In order to tell the compiler that the result should be captured, you had to add <code>@warn_unused_result</code> before the method declaration. It would be used for methods that have a mutable form (ex. sort and sortInPlace). You would add <code>@warn_unused_result(mutable_variant="mutableMethodHere")</code> to tell the compiler of it.</p>
<p>However, with Swift 3, the behavior is flipped. All methods now warn that the return value is not captured. If you want to tell the compiler that the warning isn&#8217;t necessary, you add <code>@discardableResult</code> before the method declaration.</p>
<p>If you don&#8217;t want to use the return value, you have to explicitly tell the compiler by assigning it to an underscore:</p>
<p><code>_ = someMethodThatReturnsSomething()</code></p>
<p>Why did this change in Swift 3:</p>
<ul>
<li>Prevention of possible bugs (ex. using <code>sort</code> thinking it modifies the collection)</li>
<li>Explicit intent of not capturing or needing to capture the result for other collaborators</li>
</ul>
<p>The UIKit API appears to be behind on this, not adding <code>@discardableResult</code> for the perfectly normal (if not more common) use of <code>popViewController(animated:)</code> without capturing the return value.<br />
<a href="http://useyourloaf.com/blog/swift-3-warning-of-unused-result/">Warning of unused result</a><br />
<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0047-nonvoid-warn.md">SE-0047 Swift Evolution Proposal</a></p>
<h3><strong>API Changes:</strong></h3>
<p>Apple <a href="https://github.com/apple/swift/tree/master/apinotes">keeps a list of API&#8217;s that changed</a>, the ones that have a Swift method signature. This way you can cross reference if you get any <em>&#8216;Instance method nearly matches optional requirement of protocol&#8217;</em> errors.</p>
<h3><strong>When you use your own libraries with Cocoapods.</strong></h3>
<p><a href="https://medium.com/@filipealva/cocoapods-lint-failing-with-xcode-8-a2c255e78108#.hdzuwro0x">Cocoapods fails when linting.</a></p>
<h3>Errors with Generics</h3>
<p>I&#8217;ve hit a couple of <a href="https://bugs.swift.org/browse/SR-1779">compiler</a> <a href="https://bugs.swift.org/browse/SR-2708">errors</a> which are already filled with Apple. Try to work around it or find a different solution to your problem. Unless Apple fixes this (which will probably be next version)<br />
Once all your errors are gone and you linted your project with <a href="https://github.com/realm/SwiftLint">SwiftLint</a> &#8211; <strong>now you can update to the latest project settings</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2016/10/swift-3-conversion-steps-or-the-9-steps-to-swift-bliss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Debugging in Xcode and Swift</title>
		<link>http://www.funky-monkey.nl/blog/2015/07/advanced-debugging-in-xcode-and-swift/</link>
		<comments>http://www.funky-monkey.nl/blog/2015/07/advanced-debugging-in-xcode-and-swift/#respond</comments>
		<pubDate>Sat, 04 Jul 2015 12:14:16 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1552</guid>
		<description><![CDATA[I was reading a post by Natasha The Robot about Xcode Debug Tips. (must read!) She talks about a WWDC2015 video &#8216;Advanced Debugging and the Address Sanitizer&#8216;. This shows a really cool trick for debugging. I took Natasha&#8217;s advice and I&#8217;d like to show you some more tricks of my own to help you with [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I was reading a post by Natasha The Robot about <a href="http://natashatherobot.com/xcode-debugging-trick/">Xcode Debug Tips</a>. (must read!) She talks about a WWDC2015 video &#8216;<a href="https://developer.apple.com/videos/wwdc/2015/?id=413">Advanced Debugging and the Address Sanitizer</a>&#8216;. This shows a really cool trick for debugging. I took Natasha&#8217;s advice and I&#8217;d like to show you some more tricks of my own to help you with your debugging.</p>
<p>When running a program things can just crash and Xcode and LLDB are not particularly friendly or verbose about it&#8217;s error messages. In Xcode you can have two types of breakpoints: &#8216;Workspace&#8217; and &#8216;User&#8217;. When adding a breakpoint to &#8216;Workspace&#8217; it is only visible for that project. But wouldn&#8217;t it be cool you set your breakpoints once and they show up in every project you create? ⌃-click on the breakpoint and select &#8216;Move breakpoint to =&gt; user&#8217;. Now you have that breakpoint in every project you create in Xcode.</p>
<p style="padding-left: 90px;"><a href="http://www.funky-monkey.nl/wp-content/uploads/2015/07/user_breakpoint.png"><img class=" size-full wp-image-1555 aligncenter" src="http://www.funky-monkey.nl/wp-content/uploads/2015/07/user_breakpoint.png" alt="user_breakpoint" width="652" height="260" srcset="http://www.funky-monkey.nl/wp-content/uploads/2015/07/user_breakpoint.png 652w, http://www.funky-monkey.nl/wp-content/uploads/2015/07/user_breakpoint-300x120.png 300w" sizes="(max-width: 652px) 100vw, 652px" /></a></p>
<p>In the above video, they talk about adding a breakpoint and printing the first argument. Which is actually the error message. They do this with &#8216;po $arg1&#8217;.</p>
<p>I&#8217;ve taken this example and extended it somewhat. Having a error message is nice, but I would also like to see where that error message comes from. One breakpoint is not bound to one action only &#8211; you can set up multiple actions when a breakpoint is hit. you can add sounds or backtraces. The later gives us more information about the crash.</p>
<p>⌃-click on the breakpoint and select &#8216;Edit breakpoint&#8217;, now add two actions. The first is a debugger command with &#8216;po $arg1&#8217;. And click the + to add a new action and select debugger command from the pulldown (if not already selected) and type in &#8216;bt&#8217;. This is the LLDB command for &#8216;backtrace on the current thread&#8217;. (More <a href="http://lldb.llvm.org/lldb-gdb.html">command for LLDB</a> can be found on their site.). (This should look like the image below)</p>
<p><a href="http://www.funky-monkey.nl/wp-content/uploads/2015/07/debugging_1.png"><img class=" size-full wp-image-1553 aligncenter" src="http://www.funky-monkey.nl/wp-content/uploads/2015/07/debugging_1.png" alt="debugging_1" width="835" height="337" srcset="http://www.funky-monkey.nl/wp-content/uploads/2015/07/debugging_1.png 835w, http://www.funky-monkey.nl/wp-content/uploads/2015/07/debugging_1-300x121.png 300w" sizes="(max-width: 835px) 100vw, 835px" /></a></p>
<p>When compiling again we can actually see where our crash/error is coming from and it a has a more verbose error message.</p>
<p style="padding-left: 60px;"><img class="aligncenter wp-image-1556 size-full" src="http://www.funky-monkey.nl/wp-content/uploads/2015/07/crash_backtrace.png" alt="crash_backtrace" width="695" height="360" srcset="http://www.funky-monkey.nl/wp-content/uploads/2015/07/crash_backtrace.png 695w, http://www.funky-monkey.nl/wp-content/uploads/2015/07/crash_backtrace-300x155.png 300w" sizes="(max-width: 695px) 100vw, 695px" /></p>
<p>Happy debugging <img src="https://s.w.org/images/core/emoji/2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2015/07/advanced-debugging-in-xcode-and-swift/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with iBeacons on iOS: A Guide</title>
		<link>http://www.funky-monkey.nl/blog/2014/08/playing-with-ibeacons-on-ios-a-guide/</link>
		<comments>http://www.funky-monkey.nl/blog/2014/08/playing-with-ibeacons-on-ios-a-guide/#comments</comments>
		<pubDate>Thu, 07 Aug 2014 09:08:03 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[iBeacons]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1465</guid>
		<description><![CDATA[For the last weeks I&#8217;ve been playing with beacons &#8211; these are small Bluetooth Low Energy (BLE) devices that broadcast information. iBeacons are Apple&#8217;s take on BLE. And i have to say &#8211; I&#8217;m sold. iBeacons are amazinglysuperduperawesome! Misconceptions There are some misconceptions about iBeacons and I&#8217;ll start by clearing those up. The only thing [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.funky-monkey.nl/wp-content/uploads/2014/08/IMG_0265.jpg" alt="Unfortunately I had to cut the beacons open to replace the battery" width="450" height="325" class="alignleft size-medium wp-image-1485" />For the last weeks I&#8217;ve been playing with beacons &#8211; these are small Bluetooth Low Energy (BLE) devices that broadcast information. iBeacons are Apple&#8217;s take on BLE. And i have to say &#8211; I&#8217;m sold. iBeacons are amazinglysuperduperawesome!</p>
<p><span id="more-1465"></span></p>
<p><b>Misconceptions</b><br />
There are some misconceptions about iBeacons and I&#8217;ll start by clearing those up. The only thing a (i)beacon does is broadcast information. Three bits of information to be exact, or to be more exact, three public bits of information (BLE actually sends 5 bit of information, but only 3 are public). A beacon does not get information on the internet, and a beacon does not know it&#8217;s own location. Basically it&#8217;s a very dumb device which can only say and broadcast it&#8217;s name and number.</p>
<p>The information these devices broadcast are a UUID (very unique value), a major and a minor value. (Most of the time) the UUID belongs to the vendor that sells the beacons and most of the time this is fixed in the hardware. The major and minor values are usually set to a default value and can be changes by the developer. (Some vendors allow you to change the UUID as well).</p>
<p>For my experiments I&#8217;ve used beacons by <a href="http://www.estimote.com/">Estimote</a> and <a href="http://www.estimote.com/">Roximity</a>. The later were rather useless since none of the major and minor values can be changed. Which is rather important if you want to actually DO stuff. All communication goes through their own SDK/API and CMS. I&#8217;ve also found that one of the first calls the API makes (The register call) goes directly to their back-end and send information about all running processes on your device. I send them a tweet and first they responded with this:</p>
<blockquote class="twitter-tweet" lang="en" align="center"><p><a href="https://twitter.com/sidneydekoning">@sidneydekoning</a> Hi Sidney! We collect device information to allow our merchants to provide personalized experiences. Email us for more info! — ROXIMITY (@ROXIMITY) <a href="https://twitter.com/ROXIMITY/statuses/491672118103248896">July 22, 2014</a></p></blockquote>
<p><script src="//platform.twitter.com/widgets.js" async="" charset="utf-8"></script></p>
<p>I mailed them asking them to explain a little bit more about those &#8216;personalized experiences&#8217; and they replied with this: </p>
<blockquote><p>
There are a number of things that processes on the phone help us with. One example is targeting devices known to have twitter with a deep linked URL or specific twitter based messages. Overall, we are using the data to create segments of customers that merchants can later reach back to, like shoppers or gamers. Often, it&#8217;s simply merchants want to target similar customers based on there own data, but using process we can help group them.
</p></blockquote>
<p>I&#8217;m still not sure about implementing their API &#8211; Maybe their end goal is a buyout with all this bigdata. But that is just guessing. So in the end I decided to go with Estimote. This turned out to be a solid choice. Their support is fast and to the point and their service awesome. (At one point I had to cut open all my beacons to replace the battery)</p>
<blockquote class="twitter-tweet" lang="en" align="center"><p>
<a href="https://twitter.com/sidneydekoning">@sidneydekoning</a> We&#8217;re happy to help Sidney, let us know if you need anything <img src="https://s.w.org/images/core/emoji/2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> — Wojtek Borowicz (@Esti_Wojtek) <a href="https://twitter.com/Esti_Wojtek/statuses/494106947562774528">July 29, 2014</a>
</p></blockquote>
<p><script src="//platform.twitter.com/widgets.js" async="" charset="utf-8"></script></p>
<p>So let us get back to beacons. </p>
<p><b>Development Phase: Proof of Concept</b><br />
For about two weeks I absorbed all the information I could find and created a proof of concept for a client (A big Dutch beer brand with a green logo &#8211; figure it out&#8230;). This proof of concept entailed the scanning of six beacons, linking the major an minor values to represent a value in their backend, so when an engineer walks through the brewery they get notified about when machines need maintenance and what specific part needs attention. Pretty fucking cool if I say so myself.</p>
<p><b>Developement Phase: Architecture</b><br />
Scanning for beacons is pretty straight forward. For this particular proof of concept the adding of beacons needed to be generic so I could not use the Estimote SDK unfortunately &#8211; since their SDK is pretty well thought out, architecture wise. </p>
<p>Using CoreLocation I&#8217;ve setup a location manager that manage all the beacons. From a backend call I get a JSON structure with a common name, UUID, major and minor values &#8211; this way the app always has the latest beacon description and adding new beacons to the app is a breeze. No need to release an update of the app if new beacons are added/purchased. This also solved my problem with the potential of different beacon vendors and not having to implement every single SDK that is vendor specific. (Yes I could have used the Adapter Pattern and abstracted my code and only have one interface to talk to &#8211; but having everything talk directly to the CoreLocation framework seemed like a better choice).</p>
<p>The JSON kindof looks like this:<br />
<code><br />
{<br />
	"name" : "My pretty beacon"<br />
	"UUID" : "3C074D4B-FC8C-4CA2-82A9-6E9367BBC875"<br />
	"major": 54321<br />
	"minor": 123<br />
}<br />
</code></p>
<p>After the location manager has been set up and the beacons are registered you start monitoring and then you start ranging for beacons. This is a two step process and I&#8217;ll explain what this means.</p>
<ul>
<li>Monitoring: You basically tell the system that &#8216;these are the droids you are looking for&#8217; and depends on the list of beacons you start monitoring</li>
<li>Ranging: As soon as you enter a beacon region, the ranging allows you to get the distance and proximity to the beacon itself (plus a bunch of other info). So ranging only starts when you enter a region and should be stopped when you exit a region</li>
</ul>
<p>After the <code>CLLocationManagerDelegate</code> fires <code>locationManager:didRangeBeacons:inRegion</code> you can take appropriate action per beacon. Show a UIView, get some data, etc.</p>
<p>If the iDevice is locked/screen is turned off, the background process kicks in and your app is still able to range beacons. If a beacon is found in this way the <code>locationManager:didEnterRegion</code> and <code>locationManager:didExitRegion</code> are called, depending on if you enter or exit a region. And to make proper use of this it is considered good practice to show <code>UILocalNotification</code>.</p>
<p><i>I&#8217;ve found that UILocalNotification does not have a timeout to show the notification on the lockscreen. But with sending out a notification you can also play a sound. One little hack I did is to play an empty mp3 that lasts 15 seconds. Turns out that while this is playing the notification is still showing. So there. Timeout method.</i></p>
<p><b>Distance and Proximity</b><br />
The CoreLocation framework does a lot of the heavy lifting for you calculating distance and proximity. It normalizes the fluctuating values and gives you a rather smooth end result. Even though sometimes there are some false positives. The <b>distance</b> to an beacon is an estimate in meters. This value can fluctuate between 1 meter and 3 meters even though the beacon is located 1.5 meters away from your device. Another property is <b>proximity</b>. This is calculated in region (circles) around the beacons. </p>
<p><img src="http://www.funky-monkey.nl/wp-content/uploads/2014/08/ibeacon-distance.jpg" alt="iBeacon proximity and distance" width="800" height="800" class="aligncenter" /></p>
<p>One trick to benchmark your beacons is to place them exactly one meter away (use a ruler!) and then check what the advertising interval is and signal strength, then look at the estimated value, and adjust those values to represent a meter. </p>
<p><b>Learnings</b><br />
With this there are a lot of thing that I learned, one of the most important is that I assumed that the signal strength would be stable. <i>&#8220;Assumption is the mother of all fuckup&#8221;</i> still echoes in my mind. </p>
<ul>
<li>Apple has a restriction concerning the UDID’s that cannot be circumvented. Per app a maximum of 20 UDID’s can be present.</li>
<li>The initial setup and monitoring of beacons has a latency of about 10 seconds. Also exiting a region can take some time – this is about 30 seconds and is per Apple’ implementation &#8211; sometimes even more. We, developers, have no influence in this, what so ever.</li>
<li>The actual configuration of the beacons is a very time consuming process as this has to be done per beacon. This process takes about 1.5 minutes per beacon. In a later stage it would be considered more optimal to create an app (desktop and /or mobile) to do this configuration. <i>Or just find one that does.</i></li>
<li>The signal of the beacons is, per default settings, not very stable. Playing with the signal strength (RSSI), broadcasting strength and the advertising interval makes this more stable and thus more workable. Try finding the &#8216;sweet spot&#8217; for your application.
</li>
</ul>
<p><b>The Room Finder</b><br />
For another proof of concept I hung two beacons on the doorpost of the meeting- and lunch room in our office and wrote a small app for it ‘The Room Finder’ – it uses iBeacons to show if a room is booked or not. If the room is available you can book the room at the time you desire. If the room is currently booked – You can see who is in the meeting, what the booked times for this room are, the available facilities and if it concerns the lunch room – what today’s special is. All from Google Calendar. Got my inspiration from <a href="http://techcrunch.com/2014/07/07/robin-a-company-enabling-sensor-powered-smart-offices-raises-1-35-million/" target="_blank">Robin</a>. This demo took me about 6 hours to build and another 2 to shoot and edit the video. Below is this video.</p>
<p><iframe class="wistia_embed" src="//fast.wistia.net/embed/iframe/6dn062fgjc" name="wistia_embed" width="800" height="600" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen"></iframe></p>
<p>I hope I&#8217;ve given you enough information to start playing with iBeacons yourself. If you have questions leave a comment.</p>
<p>Happy Coding <img src="https://s.w.org/images/core/emoji/2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>PS. Here are some more photo&#8217;s of the inside of the beacons. I had to cut them open to replace the battery. <a href="https://community.estimote.com/hc/en-us/articles/202552866-How-to-optimize-battery-performance-of-Estimote-Beacons-">Luckily Estimote was nice enough to replace the enclosures.</a></p>
<p><a href="http://www.funky-monkey.nl/wp-content/uploads/2014/08/beacon_1.png"><img src="http://www.funky-monkey.nl/wp-content/uploads/2014/08/beacon_1.png" alt="beacon_1" width="400" height="336" class="alignleft size-medium wp-image-1483" /></a><a href="http://www.funky-monkey.nl/wp-content/uploads/2014/08/beaon_2.png"><img src="http://www.funky-monkey.nl/wp-content/uploads/2014/08/beaon_2.png" alt="beaon_2" width="400" height="353" class="alignnone size-medium wp-image-1484" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2014/08/playing-with-ibeacons-on-ios-a-guide/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>iOS Quicky: Securing and dumping data from Keychain</title>
		<link>http://www.funky-monkey.nl/blog/2014/06/ios-quicky-securing-and-dumping-data-from-keychain/</link>
		<comments>http://www.funky-monkey.nl/blog/2014/06/ios-quicky-securing-and-dumping-data-from-keychain/#respond</comments>
		<pubDate>Tue, 17 Jun 2014 12:46:03 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1428</guid>
		<description><![CDATA[For one of the latest projects I&#8217;m working on we are relying heavily on online/offline usage and storing data in the Keychain (Apple&#8217;s safehouse for passwords and other secure stuff). For this I&#8217;m using a class provided by Apple called &#8216;KeychainItemWrapper&#8217;. You can download it from Apple&#8217;s site. My approach was simple; When my view [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img class="alignleft size-medium wp-image-1440" src="http://www.funky-monkey.nl/wp-content/uploads/2014/06/keychain-300x248.png" alt="keychain" width="300" height="248" srcset="http://www.funky-monkey.nl/wp-content/uploads/2014/06/keychain-300x248.png 300w, http://www.funky-monkey.nl/wp-content/uploads/2014/06/keychain.png 592w" sizes="(max-width: 300px) 100vw, 300px" />For one of the latest projects I&#8217;m working on we are relying heavily on online/offline usage and storing data in the Keychain (Apple&#8217;s safehouse for passwords and other secure stuff). For this I&#8217;m using a class provided by Apple called &#8216;KeychainItemWrapper&#8217;.</p>
<p>You can <a href="http://developer.apple.com/library/ios/#samplecode/GenericKeychain/Listings/Classes_KeychainItemWrapper_m.html" target="_blank">download it</a> from Apple&#8217;s site.</p>
<p>My approach was simple; When my view was loaded I would setup the Keychain and under certain circumstances I needed to clear a key/value combo, I would do this.<br />
<code><br />
- (void)viewDidLoad<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;self.keychain = [[KeychainItemWrapper alloc] initWithIdentifier:[[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"] accessGroup:nil];<br />
}<br />
...<br />
- (void)resetKeyChain<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;[self.keychain setObject:@"" forKey:(__bridge id)kSecAttrAccount];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[self.keychain setObject:@"" forKey:(__bridge id)kSecValueData];<br />
}</code><br />
Boy was I was dead wrong &#8211; it would not clear my keys from the Keychain. Took me hours to find a solution &#8211; looking for the proverbial needle in the keychain. (Debugging Keychain is a bitch. Also when deleting an app, the keychain is not cleared, which makes it next to impossible to see changes).<br />
A better approach would be to set up the Keychain like so;</p>
<p><code>- (void)viewWillAppear:(BOOL)animated<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;self.keychain = [[KeychainItemWrapper alloc] initWithIdentifier:[[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"] accessGroup:nil];<br />
}<br />
...<br />
- (void)resetKeyChain<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;[self.keychain resetKeychainItem];<br />
}<br />
</code><br />
This would clear the appropriate stuff from my Keychain and present my user with a login dialog again. Problem solved <img src="https://s.w.org/images/core/emoji/2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2014/06/ios-quicky-securing-and-dumping-data-from-keychain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Day Against DRM 2014</title>
		<link>http://www.funky-monkey.nl/blog/2014/05/day-against-drm-2014/</link>
		<comments>http://www.funky-monkey.nl/blog/2014/05/day-against-drm-2014/#respond</comments>
		<pubDate>Tue, 06 May 2014 11:12:44 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1425</guid>
		<description><![CDATA[Most of you know I fully support privacy, freedom of speech and am against vendor lock-ins. When I buy something I want to own it, because I paid for it, I want to hack and adjust that object if it does not fit my needs completely an I certainly don&#8217;t want to lease it from [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img class="alignleft" src="http://4.bp.blogspot.com/-qYKUZ7-AEqA/ToIFrS_GEEI/AAAAAAAAAs0/whrPF1qMYM8/s1600/authors-against-DRM.jpg" alt="" width="247" height="282" />Most of you know I fully support privacy, freedom of speech and am against vendor lock-ins. When I buy something I want to own it, because I paid for it, I want to hack and adjust that object if it does not fit my needs completely an I certainly don&#8217;t want to lease it from a vendor.</p>
<p>Just <a title="Day Against DRM! 50% discount!" href="http://www.funky-monkey.nl/blog/2012/05/day-against-drm-50-discount/" target="_blank">like last year</a> several online book publishers are coming together on the &#8216;Day against DRM&#8217; &#8211; download, keep or share your purchase. And I fully support this! That&#8217;s why I&#8217;m writing this post.</p>
<p><a href="http://oreil.ly/DRM-FREE-2014" target="_blank">O&#8217;Reilly</a>, who always publishes books without DRM, is doing a massive discount today by <a href="http://oreil.ly/DRM-FREE-2014" target="_blank">offering you 50% off on everything they offer</a>. You can use <strong>DRM2014 at the checkout. </strong>(Of course I would love it if you picked up a copy of <a title="I proudly present: Automating ActionScript Projects with Eclipse and Ant" href="http://www.funky-monkey.nl/blog/2011/10/i-proudly-present-automating-your-actionscript-projects-with-eclipse-and-ant/" target="_blank">my book</a> <img src="https://s.w.org/images/core/emoji/2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /><strong><br />
</strong></p>
<p><a href="http://bit.ly/1q6bpha" target="_blank">Packt</a> is offering all its DRM-free content <a href="http://bit.ly/1q6bpha" target="_blank">at $10 for 24 hours</a> only on May 6th – that’s all 2000+ eBooks and Videos.</p>
<p>So I hope you support this cause too and pick up some great books in the mean time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2014/05/day-against-drm-2014/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git autocompletion and autocorrect.</title>
		<link>http://www.funky-monkey.nl/blog/2014/04/git-autocompletion-and-autocorrect/</link>
		<comments>http://www.funky-monkey.nl/blog/2014/04/git-autocompletion-and-autocorrect/#respond</comments>
		<pubDate>Wed, 30 Apr 2014 08:52:36 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1421</guid>
		<description><![CDATA[At work i use Git *alot*. Most of the time I type too fast and my screen produces jibrish, commonly known as typos. To prevent this frmo happening, there is a fix. Git itself has a bunch of configuration options to customise behaviour, preferences and visual appearance. The manual states; help.autocorrect This option is available [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>At work i use Git *alot*. Most of the time I type too fast and my screen produces jibrish, commonly known as typos. To prevent this frmo happening, there is a fix.<br />
Git itself has <a href="http://git-scm.com/book/en/Customizing-Git-Git-Configuration">a bunch of configuration options</a> to customise behaviour, preferences and visual appearance.</p>
<p>The manual states;</p>
<blockquote><p><strong>help.autocorrect</strong></p>
<p><i>This option is available only in Git 1.6.1 and later.</i> If you mistype a command in Git, it shows you something like this:<br />
<code><br />
$ git com<br />
git: 'com' is not a git-command. See 'git --help'.</code></p>
<p>Did you mean this?<br />
commit
</p></blockquote>
<p>If you set <strong>help.autocorrect</strong> to 1, Git will automatically run the command if it has only one match under this scenario.<br />
<code>git config --global help.autocorrect 1</code><br />
The final parameter to that command is the amount of seconds, unline what the manual states. Setting it to 15 means 1.5 seconds, setting it to 1 means 0.1 seconds.</p>
<p><strong>Git Autocompletion.</strong><br />
Open up Terminal and type in the following;<br />
<code>curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion</code></p>
<p>This downloads the git-completion script and places it in your home folder.<br />
Open up ~/.bash_profile with your favorite editor and add the following line at the end of it.</p>
<p><code>source ~/.git-completion</code></p>
<p>You are now good to go. No open a new Terminal tab or force this command by &#8216;refreshing&#8217; the terminal by typing <code>source ~/.bash_profile</code> Still in Terminal type <code>git com</code> and press the tab key. This should either autocomplete the command or if there are more commands starting with &#8216;com&#8217; show you a list of possible options.</p>
<p>Enjoy! No moer typos in Git.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2014/04/git-autocompletion-and-autocorrect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UncrustifyX to use with your Xcode 5 formatting needs</title>
		<link>http://www.funky-monkey.nl/blog/2014/02/uncrustifyx-to-use-with-your-xcode-5-formatting-needs/</link>
		<comments>http://www.funky-monkey.nl/blog/2014/02/uncrustifyx-to-use-with-your-xcode-5-formatting-needs/#comments</comments>
		<pubDate>Thu, 13 Feb 2014 09:25:48 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1401</guid>
		<description><![CDATA[For the past couple of days I&#8217;ve embedded myself in Xcode and making the most out of Xcode, using plugins and generally getting to know one another. Yesterday figured out how to do proper code formatting using Uncrustify. I&#8217;ve looked at multiple formatting templates and after playing around with several tools, I decided to use [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>For the past couple of days I&#8217;ve embedded myself in Xcode and making the most out of Xcode, using plugins and generally getting to know one another. Yesterday figured out <a title="From frustration comes inspiration – Source formatting in Xcode 5" href="http://www.funky-monkey.nl/blog/2014/02/from-frustration-comes-inspiration-source-formatting-in-xcode-5/">how to do proper code formatting using Uncrustify</a>. I&#8217;ve looked at multiple formatting templates and after playing around with <a href="http://sourceforge.net/projects/universalindent/" target="_blank">several</a> tools, I decided to use <a href="https://github.com/ryanmaxwell/UncrustifyX/releases" target="_blank">UncrustifyX</a>. It is a visual tool to play around and create your own code formatting style. I&#8217;ve tweaked, churned and crunched out my own formatting style for others to play around as well which you can find on my <a href="https://gist.github.com/funky-monkey/8971924" target="_blank">GitHub</a> account.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2014/02/uncrustifyx-to-use-with-your-xcode-5-formatting-needs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>From frustration comes inspiration &#8211; Source formatting in Xcode 5+</title>
		<link>http://www.funky-monkey.nl/blog/2014/02/from-frustration-comes-inspiration-source-formatting-in-xcode-5/</link>
		<comments>http://www.funky-monkey.nl/blog/2014/02/from-frustration-comes-inspiration-source-formatting-in-xcode-5/#comments</comments>
		<pubDate>Wed, 12 Feb 2014 10:55:12 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1388</guid>
		<description><![CDATA[[UPDATE: To fix this for Xcode 5.1 &#8211; please scroll to the bottom of this page] From frustration comes inspiration &#8211; one of my biggest frustrations while using Xcode is that there is no build in way to do code formatting. Well ok, you do have &#8216;re-ident&#8217; but that is mostly a manual process and [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img class="wp-image-1402 alignleft" style="border: 0px none;" alt="Tools Workshop" src="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Tools-Workshop_c_linda_mcnulty.bmp" width="500" /><strong>[UPDATE: To fix this for Xcode 5.1 &#8211; please scroll to the bottom of this page]</strong></p>
<p>From frustration comes inspiration &#8211; one of my biggest frustrations while using Xcode is that there is no build in way to do code formatting. Well ok, you do have &#8216;re-ident&#8217; but that is mostly a manual process and i like using the keyboard. Also this is not quite what I was after.</p>
<p>After some searching I found <a href="http://uncrustify.sourceforge.net/">Uncrustify</a> a generic &#8220;Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA&#8221;. I checked out the sourcecode, build it and placed the newly created binary in my bin folder. Next up was this <a href="https://github.com/benoitsan/BBUncrustifyPlugin-Xcode">Xcode plugin</a>. Easiest and fastest way to get this on your system is by <a href="https://github.com/benoitsan/BBUncrustifyPlugin-Xcode#installation">unzipping the binary</a> and placing it in your <code>~/Library/Application Support/Developer/Shared/Xcode/Plug-ins</code> folder. Don&#8217;t forget to restart Xcode after you do this.</p>
<p>After you restarted Xcode, you can open the plugin by navigating to <code>Edit -&gt; Format Code</code></p>
<ul>
<li>Use the menu <strong><code>Format Selected Files</code></strong> to format the selected items in the project navigator.</li>
<li>Use the menu <strong><code>Format Active File</code></strong> to format the source file actually opened in the editor.</li>
<li>Use the menu <strong><code>Format Selected Lines</code></strong> to format the selected source code (multiple selection is supported). The selection is automatically extended in full lines. If the selection is empty, it uses the line under the cursor.</li>
<li>Use the menu <strong><code>Edit Configuration</code></strong> to edit the formatter configuration in an external editor.</li>
<li>Use the menu <strong><code>BBUncrustifyPlugin Preferences</code></strong> to change the plugin preferences.</li>
</ul>
<p>The real magic happens when you assign it to a key binding. Unfortunately this cannot be done in Xcode and have to be done system wide. So go to <code>System Preferences -&gt; Keyboard</code>. Under Keyboard Shortcuts select &#8216;Application Shortcuts&#8217; and press the plus sign to add a new program. Select Xcode and call it <strong>Format Active File</strong>. The naming is very important to be exactly the same as the actual item in Xcode. Naming it differently makes it unusable.<br />
<img class="alignnone size-full wp-image-1389" style="border: 0px none;" alt="Screen Shot 2014-02-12 at 11.22.07 AM" src="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-12-at-11.22.07-AM.png" width="782" height="712" srcset="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-12-at-11.22.07-AM.png 782w, http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-12-at-11.22.07-AM-300x273.png 300w" sizes="(max-width: 782px) 100vw, 782px" /></p>
<p><strong>Formatting.</strong><br />
You can also use different configurations for your own source code. If you create a directory called <code><strong>.uncrustify</strong></code> in your user home directory and check out <a href="https://github.com/dijkst/uncrustify-config-ios">this repository</a> in that location, you have a very good starting point for your own formatting style. If you have questions regarding the formatting and indentation etc, there is a lot of answers on <a href="http://stackoverflow.com/tags/uncrustify/">StackOverflow</a>, be sure to check it out if you want to make your own formatting magic happen.</p>
<p style="text-align: left;">When you go back to Xcode and you see a key binding next to the <strong><code>Format Selected Files</code></strong> you know everything worked out.</p>
<p style="text-align: center;"><img class="size-full wp-image-1392 aligncenter" style="border: 0px none;" alt="Screen-Shot-2014-02-12-at-11.35.37-AM" src="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-12-at-11.35.37-AM.png" width="600" height="514" srcset="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-12-at-11.35.37-AM.png 600w, http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-12-at-11.35.37-AM-300x257.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p><em>Et voilà</em>! Pressing that key combo adds magic/formats your source code in the flavor you like. Enjoy!</p>
<p>[UPDATE]<br />
To make this work for Xcode 5.1 find the plugin file, right click on the file and select &#8216;Show Package Contents&#8217; and open up the Info.plist in a plain text editor. Then look for the key <code>DVTPlugInCompatibilityUUIDs</code> and add <code>A2E4D43F-41F4-4FB9-BB94-7177011C9AED</code> under the last entry. Save and reopen Xcode. Tada!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2014/02/from-frustration-comes-inspiration-source-formatting-in-xcode-5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adding keybindings in Xcode 5</title>
		<link>http://www.funky-monkey.nl/blog/2014/02/adding-keybindings-in-xcode-5/</link>
		<comments>http://www.funky-monkey.nl/blog/2014/02/adding-keybindings-in-xcode-5/#comments</comments>
		<pubDate>Mon, 10 Feb 2014 12:45:00 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1379</guid>
		<description><![CDATA[I&#8217;ve been using Xcode for quite a while now, but it still takes some getting used to. Today I had enough and wanted to add my own bindings for &#8220;duplicate current line&#8221; and &#8220;delete current line&#8221;, something i&#8217;ve been used to in FDT. I&#8217;ve found some resources that help me on my way, so here [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been using Xcode for quite a while now, but it still takes some getting used to. Today I had enough and wanted to add my own bindings for &#8220;duplicate current line&#8221; and &#8220;delete current line&#8221;, something i&#8217;ve been used to in FDT.</p>
<p>I&#8217;ve found <a href="https://developer.apple.com/library/mac/recipes/xcode_help-keybindings_preferences/articles/AddingaCustomKeyboardShortcutCommandSet.html">some</a> <a href="http://stackoverflow.com/questions/10266170/xcode-duplicate-line">resources</a> <a href="http://stackoverflow.com/questions/551383/xcode-duplicate-delete-line">that</a> help me on my way, so here is a quick reminder/walk through to do it (I don&#8217;t take credit for exposing this method, i just use it). It takes about 3 minutes to set up and can save you *a lot* of frustration.</p>
<ol>
<li>Find <strong><code>IDETextKeyBindingSet.plist</code> </strong>in the folder <code><strong>/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/</strong> Resources</code>, get the file info and change the rights to &#8220;read &amp; write&#8221; for user everyone. This allows you to make changes to the file. Now open it in Xcode.</li>
<li>Add a new key as a Dictionary and call it <strong><code>Customized</code></strong> and add a String.<br />
<a href="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.16.01-PM.png"><img class="wp-image-1381 alignnone" style="border: 0px none; margin: 0px;" alt="Screen Shot 2014-02-10 at 1.16.01 PM" src="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.16.01-PM-1024x641.png" width="789" height="494" srcset="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.16.01-PM-1024x641.png 1024w, http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.16.01-PM-300x187.png 300w, http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.16.01-PM.png 1214w" sizes="(max-width: 789px) 100vw, 789px" /></a></li>
<li>As String key add <strong><code>Duplicate Current Line</code></strong> and as value fill in <strong><code>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</code></strong></li>
<li>As String key add <strong><code>Delete Current Line</code></strong> and as value fill in <strong><code>deleteToBeginningOfLine:, moveToEndOfLine:, deleteToBeginningOfLine:, deleteBackward:, moveDown:, moveToBeginningOfLine:</code></strong>. Save file and close and reopen Xcode.</li>
<li>Now go into &#8220;Key Bindings&#8221; under &#8220;Preferences&#8221; and press <strong><code>Customized<br />
<a href="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.15.41-PM.png"><img class="alignnone  wp-image-1380" style="border: 0px none; margin: 0px;" alt="Screen Shot 2014-02-10 at 1.15.41 PM" src="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.15.41-PM.png" width="691" height="531" srcset="http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.15.41-PM.png 864w, http://www.funky-monkey.nl/wp-content/uploads/2014/02/Screen-Shot-2014-02-10-at-1.15.41-PM-300x230.png 300w" sizes="(max-width: 691px) 100vw, 691px" /></a><br />
</code></strong></li>
<li>Now give the two newly added key bindings the binding you&#8217;d like, i&#8217;ve set mine to CMD-D for deleting a line and CMD-SHIFT-D for duplicating a line.</li>
<li>Enjoy!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2014/02/adding-keybindings-in-xcode-5/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Code Reviews</title>
		<link>http://www.funky-monkey.nl/blog/2014/02/code-reviews/</link>
		<comments>http://www.funky-monkey.nl/blog/2014/02/code-reviews/#respond</comments>
		<pubDate>Thu, 06 Feb 2014 17:21:20 +0000</pubDate>
		<dc:creator><![CDATA[Sidney de Koning]]></dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.funky-monkey.nl/blog/?p=1333</guid>
		<description><![CDATA[For the last months I&#8217;ve been doing a lot of Objective-C. Got a new job and only focus on iOS development. Since I am the new guy in the team, I learn a lot by looking at code from my peers (and looking at code in general). And even though I have a lot of [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="text-align: left;"><a href="http://www.funky-monkey.nl/wp-content/uploads/2014/02/code_review5.jpeg"><img class=" wp-image-1338 alignleft" alt="code_review5" src="http://www.funky-monkey.nl/wp-content/uploads/2014/02/code_review5-225x300.jpeg" width="205" height="273" srcset="http://www.funky-monkey.nl/wp-content/uploads/2014/02/code_review5-225x300.jpeg 225w, http://www.funky-monkey.nl/wp-content/uploads/2014/02/code_review5.jpeg 358w" sizes="(max-width: 205px) 100vw, 205px" /></a>For the last months I&#8217;ve been doing a lot of Objective-C. Got a new job and only focus on iOS development. Since I am the new guy in the team, I learn a lot by looking at code from my peers (and looking at code in general). And even though I have a lot of ActionScript experience under my belt, I&#8217;m starting fresh with Objective-C. Frustrating at times, awesome most of the time. I love being the new guy. I get to ask dumb questions, can still write silly code and make a lot of beginners mistakes. And challenge my peers by having <a href="http://en.wikipedia.org/wiki/Shoshin">Shoshin</a> or beginners mind.</p>
<p style="text-align: left;">One of the things I really love is code-reviews by my peers, they are mandatory at the place I work. They basically go through my code and comment on it when I fuck up or make dumb mistakes. Lately I had to return the reviewing favor.</p>
<p style="text-align: left;">Looking through code of my co-workers and myself I noticed a couple of things and thought it would make a good bit for an article. I&#8217;ll go through as much of the bad stuff I can find and discuss them here. As habits are hard to change, get in the habit of changing them as soon as you see them in your own code. This is by no means a definitive list and if you have suggestions for more, let me know in the comments.</p>
<p style="text-align: left;"><strong>1. Commented Code</strong><br />
Since you use a VCS like Git or SVN, there is absolutely no need to leave commented code in your source files since you can always revert. <strong>So remove it.</strong></p>
<p style="text-align: left;"><strong>2. Duplicate Code / KISS</strong><br />
If you have a lot of duplicate code all over the place &#8211; you are doing it wrong. <a href="http://en.wikipedia.org/wiki/KISS_principle">KISS</a> and refactor (see point 6.)</p>
<p style="text-align: left;"><strong>3. NSLogs</strong><br />
Since Apple defines logging *only* <a href="https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/LoggingErrorsAndWarnings.html#//apple_ref/doc/uid/10000172i-SW8-SW3">for errors</a>, a better way to get information from your app is by utilizing your debugger. There have been <a href="http://doing-it-wrong.mikeweller.com/2012/07/youre-doing-it-wrong-1-nslogdebug-ios.html">numerous</a> articles about not using NSLog in (production) code and why it&#8217;s better to use a breakpoint. The cool thing about breakpoints in XCode is that you can use <a href="http://furbo.org/2013/04/11/logging-with-xcode-breakpoints/">non-breaking breakpoints that send a message to the output window</a>.</p>
<p style="text-align: left;"><strong>4. Retarded and/or short unreadable variable names</strong><br />
No matter what language you write code in, you always need to make sure it is readable. For your team members or for yourself when you come back to a project a year from now. This includes the correct naming of variables. Since Objective-C is by itself a very verbose language, variable name tend to have the same tendency. Using myReallyLongVariableName is oke, since compilers nowadays are optimized to deal with this. Verbosity and readability over brevity and difficulty to read code.</p>
<p style="text-align: left;"><strong>5. Small is beautiful</strong><br />
Just like an app or program, methods need to do one thing only and do that one thing well. Like the <a href="http://www.ru.j-npcs.org/usoft/WWW/LJ/Articles/unixtenets.html">UNIX philosophy</a>.  That&#8217;s what I&#8217;m taught and still believe. Don&#8217;t bloat your methods with doing six things. This makes it very difficult to read, understand and debug. Small is beautiful.</p>
<p style="text-align: left;"><strong>6. OOP.</strong><br />
What I see *a lot* is that people don&#8217;t know how to use proper OO. Not knowing how to extend classes or know how to design to a protocol (Objective-C&#8217;s term for interfaces) is basic stuff. Don&#8217;t be afraid to ask your peers, even if you&#8217;ve are an (iOS) senior.</p>
<p style="text-align: left;"><strong>7. Design Patterns.</strong><br />
While design patterns are not a magical, ready made solution or a silver bullet if you will, i do advise you to get <a href="http://www.apress.com/9781430233305">a proper book on design patterns</a> and learn about Model View Controller (MVC), Key Value Observation (KVO) / Observers and Delegation. These are the fundamentals of iOS programming.</p>
<p style="text-align: left;"><strong>8. Refactoring</strong><br />
The problem with writing code is that there is always ego involved. Even in <a href="http://www.codinghorror.com/blog/2006/05/the-ten-commandments-of-egoless-programming.html">ego-less programming</a> (MUST READ!). That one brilliant solution you created for that one project will look like crap to another team member. People see things in different ways and that is oke. People do things to solve problems. Don&#8217;t try to rewrite everything just because it doesn&#8217;t look proper to you, try to put yourself in their shoes when they wrote this piece of code you are looking at. And breathe.</p>
<p style="text-align: left;"><strong>9. Lose the Ego</strong><br />
Reality check: Your code is not you. What? <em>Your code is not you</em>. It is just a solution to a problem, even though sometimes a <strong>very</strong> good solution. Don&#8217;t think you are the only one that can have good solutions. I don&#8217;t. (Well I actually do, sometimes &#8211; but I&#8217;m learning) The best solution come from unexpected corners or people. Even veterans make thinking mistakes, I know I do. <a href="http://www.codinghorror.com/blog/2006/05/the-ten-commandments-of-egoless-programming.html">And lose the ego</a>. Realizing that makes you grow and makes better software.</p>
<p style="text-align: left;"><strong>10. Take responsibility</strong><br />
The next person that says &#8220;Nah that wasn&#8217;t me that wrote this&#8221; will get a kick in the groin. Seriously. I truly believe developers in general need to take responsibility for the code they create. Not taking responsibility is not believing what you wrote in the first place. You do care about your code right? Otherwise you are in this for the wrong reasons. Making a mistake is not the worst thing that can happen, it&#8217;s just a piece of code we are taking about. So have some balls.</p>
<p><strong>BONUS. My debugging mantra</strong><br />
As I already mentioned on <a href="https://twitter.com/sidneydekoning/status/381814859912183808">Twitter some time ago</a>; <strong>Bugs are communication errors between you and the machine and can be fixed by asking &#8216;what do you think i said and why do you think that?&#8217;</strong><em><strong>.</strong> </em>Taking this step back can help you debug faster.<em><br />
</em></p>
<p style="text-align: left;">So. Embrace change, be open, don&#8217;t be cocky, loose the ego, look with children&#8217;s eyes, have a shoshin mind and enjoy what you are doing &#8211; only then will you grow as a coder.</p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://www.funky-monkey.nl/blog/2014/02/code-reviews/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
