<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aaron Brager on Medium]]></title>
        <description><![CDATA[Stories by Aaron Brager on Medium]]></description>
        <link>https://medium.com/@getaaron?source=rss-69af151a6812------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1nFL0maA2rCCgliecYJeMg.jpeg</url>
            <title>Stories by Aaron Brager on Medium</title>
            <link>https://medium.com/@getaaron?source=rss-69af151a6812------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:12:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@getaaron/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[7 Tips for Web Developers and Software Engineers Learning iOS Development]]></title>
            <link>https://medium.com/ios-os-x-development/7-tips-for-web-developers-and-software-engineers-learning-ios-development-8f75b3a1707?source=rss-69af151a6812------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f75b3a1707</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Aaron Brager]]></dc:creator>
            <pubDate>Wed, 16 Dec 2015 20:11:18 GMT</pubDate>
            <atom:updated>2015-12-16T20:28:25.976Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Learning to write iOS apps and already know another programming language? Here are a few tips.</p><blockquote>If you’re a beginner, “<a href="https://medium.com/ios-os-x-development/should-i-learn-swift-or-objective-c-for-ios-development-1096b42fcd19#.3b0p5dum0">Should I learn Swift or Objective-C for iOS development?</a>” may be more interesting.</blockquote><h3>1. Start by Exploring Xcode</h3><p>Unlike many other development environments, an iOS application development environment is easy to configure. Here are the steps:</p><ol><li><a href="https://itunes.apple.com/us/app/xcode/id497799835?mt=12">Download and install Xcode</a> from the App Store</li><li>Create an <a href="https://developer.apple.com/membercenter/">Apple Developer Account</a> (free)</li></ol><p>There’s ample command-line access if you want automation or need advanced workflows, but most work can be done within Xcode.</p><p>Xcode combines a powerful code text editor with graphical interfaces to a compiler, linter, debugger, user interface builder, documentation, and more. If you’re coming from a world where those are all separate, you’re in for a treat.</p><h3>2. Decide Between Swift and Objective-C</h3><p>One of the first choices you’ll make is which language to learn: Swift or Objective-C. Swift is newer and more modern, but it’s <em>conceptually different</em> from many web programming languages. Unlike Ruby and JavaScript, for example, Swift requires <em>nil</em>-checking and has strict type safety, including for collections. Objective-C is a freer language, more similar to Ruby and JavaScript, but with some weird syntax, verbose language, and less intuitive conventions.</p><p>Objective-C has a few advantages:</p><ol><li>Its syntax and usage is stable: tutorials and code samples from years ago work with only minor modifications.</li><li>It’s very popular: most iOS app code bases are primarily written in Objective-C.</li><li>Most iOS Developer job openings require Objective-C knowledge.</li></ol><p>Swift has some strong advantages over Objective-C, though:</p><ol><li>A REPL, with an accompanying graphical interface called a “playground”. <em>(A REPL is a console interface to a programming language, like irb, Pry, or node.)</em></li><li>Swift has <a href="https://developer.apple.com/swift/resources/">a great library</a> from Apple of manuals, tutorials, and videos.</li><li>It’s open-source, so you can see how it works and change it.</li></ol><p><a href="https://www.coursereport.com/blog/developing-for-ios-objective-c-vs-swift-webinar">This video</a> explores the differences a bit more. Both languages are powerful and full-featured, and both have full use of the iOS SDK.</p><p>If you’re not sure, I recommend starting with Objective-C, since that’s where the bulk of the job openings are at the moment. But you can’t go wrong either way.</p><h3>3. Learn the Debugging Tools</h3><p>Xcode’s debugging tools are among the industry’s best. Learn to use them for fast and efficient debugging and performance improvements. Some quick tips:</p><ul><li>Set a breakpoint by clicking on the line number. When the line is reached, execution will pause.</li><li>Hover your mouse over a variable to see into its contents.</li><li>Click a variable and press space bar to see a visual representation of its data (for example, if it’s an image or a color).</li><li>Use LLDB to debug your app while execution is paused.</li><li>Use Static Analysis to find logical flaws in your code.</li></ul><p>Here are some resources to get started:</p><ul><li><a href="https://developer.apple.com/videos/wwdc/2012/?id=412">Debugging in Xcode (2012 video; a bit dated but still helpful)</a></li><li><a href="https://www.objc.io/issues/19-debugging/lldb-debugging/">Dancing in the Debugger — A Waltz with LLDB</a></li><li><a href="https://developer.apple.com/videos/play/wwdc2015-402/">What’s New in LLDB (video)</a></li></ul><h3>4. Learn to Decipher Square Brackets</h3><p>This method syntax is widely considered to be ugly:</p><pre>[self.view insertSubview:button atIndex:2];</pre><p>Confused? Don’t be:</p><ul><li>The first statement is the object that the method is called on (the <em>receiver</em>).</li><li>The remaining statements are the method name interwoven with arguments:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*zw5ijDaMWWeWA5bXV70YWw@2x.png" /></figure><p>In Swift, the same method call looks a lot more like JavaScript or Ruby:</p><pre>view.<strong>insertSubview</strong>(button, <strong>atIndex</strong>: 2)</pre><p>Learning to quickly interpret Objective-C square bracket notation is critical to your success as an iOS developer. Even if you’re working on apps in Swift, you’ll likely read sample code in Objective-C.</p><h3><strong>5. </strong>Don’t Be Intimidated by Objective-C’s Verbosity</h3><p>Say you have a string like <em>‘2,4,5’</em> that you’d like to convert to an array. In a language like Ruby you’d use <em>split</em>:</p><pre>&#39;2,4,5&#39;.split(&#39;,&#39;)</pre><p>Objective-C has a similar feature, but its syntax is much more verbose:</p><pre>[@&quot;2,4,5&quot; componentsSeparatedByString:@&quot;,&quot;];</pre><p>Want to turn that array back into a string? Objective-C doesn’t have <em>join</em>; it has:</p><pre>[@[@&quot;2&quot;, @&quot;4&quot;, @&quot;5&quot;] componentsJoinedByString:@&quot;,&quot;];</pre><p>Objective-C naming conventions are more verbose than those in many other languages. It’s tempting to think that these methods are more complicated — or harder — because they’re longer, but they’re not.</p><p>Just like with the previous tip, even if you plan to work solely in Swift, it’s important to understand Objective-C’s style so you can read and interpret it correctly.</p><h3><strong>6. Understand Object vs. Value Semantics</strong></h3><p>In Ruby, everything’s an object. The same is (mostly) true of JavaScript. But in Objective-C there’s an important separation between primitive (value) types and objects. To bridge the gap, wrap primitive types in an <strong>NSValue</strong> or <strong>NSNumber</strong> object. For example:</p><pre>// ERROR: implicit conversion is disallowed<br><strong>[mutableArray addObject:7];</strong></pre><pre>// Works great<br><strong>[mutableArray addObject:[NSNumber numberWithInt:7]];</strong></pre><pre>// You can also use this shorthand<br><strong>[mutableArray addObject:@(7)];</strong></pre><p>In Objective-C, object semantics are required. In Swift, you can use objects or values for most things, but values are strongly preferred. This is another strong difference between Swift and most web programming languages.</p><blockquote>If you’re working in Swift, read <a href="https://developer.apple.com/swift/blog/?id=10">Value and Reference Types</a>, and watch the <a href="https://developer.apple.com/videos/play/wwdc2015-414/">Building Better Apps with Value Types in Swift</a> video.</blockquote><h3>7. Understand Automatic Reference Counting</h3><p>Objective-C and Swift apps (mostly) manage memory using <em>Automatic Reference Counting</em> (ARC). This contrasts with languages like Ruby, JavaScript, and Java, which use <em>Garbage Collection</em>.</p><p>In ARC, objects stay in memory if there is at least one <em>strong </em>reference to it. For example:</p><pre>self.label.text = @&quot;Hello World&quot;;</pre><p>In this example, the string object (<em>@“Hello World”</em>) will stay in memory because it has one strong reference (from <em>label</em>). Now consider this:</p><pre>self.label = nil;</pre><p>Two things will happen:</p><ul><li>The label object will be deallocated because <em>self</em> is no longer referencing it</li><li>The string object will be deallocated because <em>label</em> no longer exists, and therefore is no longer referencing the string</li></ul><p>Be careful not to create a <em>strong reference cycle</em> (also called a <em>retain cycle</em>). This is an error caused by a circular graph of objects pointing to each other. It wastes memory and can cause other negative side effects. Here’s an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*Te7GYoNS6O3--lKxyA1rUw@2x.png" /></figure><p>Because all of these objects have at least one strong reference, none of them will ever be deallocated. To resolve this, switch one of the references from <em>strong</em> to <em>weak</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*QWBMmqQGmPpCFX7puL4HKA@2x.png" /></figure><p>With a weak reference, if the <em>CarDealership</em> instance gets deallocated, all of its cars will get deallocated as we’d expect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*YC5GZXRrc2t2tg0IsbnlLw@2x.png" /></figure><p>Thanks for reading these tips. I hope you found a few of them helpful. <a href="https://www.twitter.com/getaaron">Follow me on Twitter</a> if you’d like to get in touch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*YC5GZXRrc2t2tg0IsbnlLw@2x.png" /></figure><p>If you’re interested in learning more by pair programming with a senior iOS developer, check out <a href="https://try.bloc.io/ios-for-developers/?utm_campaign=medium-8-tips">Bloc’s <em>iOS for Engineers</em> course</a>.</p><figure><a href="https://try.bloc.io/ios-for-developers/?utm_campaign=medium-8-tips"><img alt="" src="https://cdn-images-1.medium.com/max/268/1*2yaww8slMM7nHE1VoiEsUA@2x.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f75b3a1707" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ios-os-x-development/7-tips-for-web-developers-and-software-engineers-learning-ios-development-8f75b3a1707">7 Tips for Web Developers and Software Engineers Learning iOS Development</a> was originally published in <a href="https://medium.com/ios-os-x-development">iOS App Development</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unregistering from iMessage still doesn’t work for group messages]]></title>
            <link>https://medium.com/@getaaron/unregistering-from-imessage-still-doesn-t-work-for-group-messages-3f1b43923f5?source=rss-69af151a6812------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f1b43923f5</guid>
            <category><![CDATA[imessage]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Aaron Brager]]></dc:creator>
            <pubDate>Thu, 07 May 2015 21:39:07 GMT</pubDate>
            <atom:updated>2015-05-08T16:30:04.762Z</atom:updated>
            <content:encoded><![CDATA[<p>There was some mild Internet controversy in 2014 because iPhone-to-Android switchers <a href="http://www.theverge.com/2014/5/22/5741128/apple-may-fix-notorious-imessage-purgatory-bug">weren’t getting texts</a> from iMessage users after leaving the iOS platform.</p><p>This has mostly been resolved due to <a href="https://selfsolve.apple.com/deregister-imessage">Apple’s Deregister iMessage tool</a>, but group messages still fail.</p><blockquote>If a person unregisters from iMessage, <strong>group conversations are still sent through iMessage </strong>and are<strong> never received by the person who unregistered</strong>.</blockquote><h4>Reproduction Steps</h4><p>This is easy to reproduce if you have three iPhones lying around:</p><ol><li>Activate three iPhones. (Call them Alan, Betty, and Charlie’s phones.)</li><li>Start a group iMessage from one to the other two.</li><li>Deactivate iMessage on Alan’s iPhone.</li><li>Move Alan’s SIM card to an Android phone.</li><li>Send a message from Betty’s phone to the group thread.</li></ol><p>The message from Betty <strong>should</strong> be delivered to the recipients over SMS (green bubbles) since Alan no longer uses iMessage.</p><p>Here’s what actually happens:</p><ul><li>To Betty, the message falsely appears to be sent successfully.</li><li>Charlie receives the message because he has iMessage.</li><li>Alan is never notified of the message because he only has SMS and the message was sent over iMessage.</li></ul><p>This happens on the latest version of iOS. It only affects group messages; individual (non-group) conversations revert to SMS as expected.</p><h4>Additional Problems</h4><p>If Betty deletes the entire group thread and starts a new one, it will send over SMS as expected. However, when Charlie replies to Betty’s message, it will be sent over iMessage and won’t be received by Alan.</p><p>Also, once Charlie sends this reply, Betty’s thread will switch back over to iMessage, and future messages won’t be received by Alan.</p><h4>Workaround</h4><p>The only way to resolve this issue is for Betty and Charlie to coordinate with each other, and both delete their group threads with Alan simultaneously. The conversation will then continue over SMS when someone starts a new one.</p><p>Follow me on Twitter:</p><p><a href="https://twitter.com/getaaron">Aaron Brager (@getaaron) | Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f1b43923f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Should I learn Swift or Objective-C for iOS development?]]></title>
            <link>https://medium.com/ios-os-x-development/should-i-learn-swift-or-objective-c-for-ios-development-1096b42fcd19?source=rss-69af151a6812------2</link>
            <guid isPermaLink="false">https://medium.com/p/1096b42fcd19</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[objective-c]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Aaron Brager]]></dc:creator>
            <pubDate>Thu, 05 Mar 2015 16:31:38 GMT</pubDate>
            <atom:updated>2015-06-22T16:52:23.945Z</atom:updated>
            <content:encoded><![CDATA[<p>Beginner students will be better served by initially learning Objective-C. Here’s why:</p><ul><li>Companies aren’t hiring Swift-only developers yet</li><li>iOS Developers still need to know Objective-C</li><li>Swift is harder to learn</li><li>Swift is constantly changing</li></ul><p>Swift is good for existing developers who already know Mac or iOS development and want to learn — and help shape — a new language. Beginner developers who just want to experiment, don’t want to get an iOS developer job, and don’t mind dealing with extra bugs while they’re learning, may be interested in learning it as well.</p><p>Students need to be prepared to use Swift as these problems get resolved in the future, so at <a href="http://www.bloc.io/ios">Bloc</a>, we teach some Swift along with Objective-C.</p><h3>Companies aren’t hiring Swift developers yet</h3><p>The App Store contains about 1.2 million apps, mostly written in Objective-C. Nearly all of the thousands and thousands of iOS developer job openings today require Objective-C knowledge. Most of the job listings that mention Swift want senior developers with Swift <em>and</em> Objective-C chops.</p><p>Colin Eberhardt put together some <a href="http://www.scottlogic.com/blog/2014/08/01/swift-vs-objectivec.html">informal Swift adoption statistics</a> in August 2014. He concludes:</p><blockquote>iOS development activity is still predominantly Objective-C, with roughly 3x more activity vs. Swift.</blockquote><p>He also notices spikes in Objective-C activity on weekdays, possibly indicating that Swift is currently more of a hobby.</p><h3>iOS Developers still need to know Objective-C</h3><p>Even if you’re writing an app for yourself and you’re uninterested in a new job, you still need to know Objective-C to be a good iOS developer.</p><p>Big Nerd Ranch teacher <a href="http://www.bignerdranch.com/blog/ios-developers-need-to-know-objective-c/">Aaron Hillegass outlines a number of reasons</a>. Among them, you’ll want to use third-party libraries in your app. (Libraries contain reusable, time-saving code. For example, <a href="https://github.com/facebook/pop">Facebook’s popular Pop library</a> makes physics-based interactions easy.) Most battle-tested third-party libraries are written in Objective-C. To understand and use these libraries, you’ll need to be able to read them. Additionally, most tutorials, blog posts, and Stack Overflow questions are written in Objective-C. You’ll have more trouble learning if you can’t understand these posts.</p><h3>Swift is harder to learn</h3><p>Although Swift is friendlier-looking, it’s more complex and harder to learn than Objective-C.</p><p>Brent Simmons, a prominent Mac and iOS developer, <a href="http://inessential.com/2015/02/04/random_swift_things">describes it well</a>:</p><blockquote>Objective-C looks hard because of the [ and ] syntax and all those words. It looks kind of <em>mean</em>, actually, like an angry grandpa with bushy eyebrows who makes you spell out “I am laughing out loud” instead of writing LOL.</blockquote><blockquote>But Objective-C is easy compared to Swift. Swift <em>looks</em> easier at first blush — every JavaScript developer sees it as familiar, and many think that this might be their way into writing native apps.</blockquote><p>Swift has many nuances to learn, which you don’t need to learn in Objective-C. For example, there’s different behavior for <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ClassesAndStructures.html#//apple_ref/doc/uid/TP40014097-CH13-ID82">classes and structures</a>, <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/OptionalChaining.html#//apple_ref/doc/uid/TP40014097-CH21-ID245">optional chaining</a>, <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Generics.html#//apple_ref/doc/uid/TP40014097-CH26-ID179">generic types</a>, strict <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-ID322">type safety</a>, and more.</p><p>These additions are all welcome, but they add complexity and advanced features that beginners don’t need to learn initially.</p><p>Aside from its funny-looking syntax, Objective-C is an easier language for beginner developers to learn.</p><h3>Swift is constantly changing</h3><p>New versions of Swift are released frequently. Since Bloc released a free <a href="https://www.bloc.io/swiftris-build-your-first-ios-game-with-swift">Swiftris Tutorial</a>, we’ve made four revisions to keep it up-to-date with the latest version of Swift. And new beta versions are already out, so we’ll have more revisions to make in the future. This update frequency is unusual for an established language like Objective-C, which receives minor updates about annually.</p><p>As a beginner, it’s challenging enough learning to write code. If you learn Swift first, you’re setting yourself up for derailment if a Swift update is released just as you’re starting to grasp a new concept.</p><p>For example: on June 8, 2015, Apple <a href="https://developer.apple.com/swift/blog/?id=29">announced Swift 2.0</a>. It contains many great changes, some of which break existing code. Although Xcode includes an excellent migration tool, beginners shouldn’t need to hit a constantly-shifting target.</p><h3>Bloc teaches both Objective-C and Swift</h3><p>The good news is, once you’ve learned Objective-C, learning Swift will be much easier. At Bloc, we prepare all of our students for a future where Swift is stable and required. All Bloc students learn the basics of Swift syntax and must complete some Swift exercises to demonstrate understanding.</p><p>During the projects phase of the apprenticeship, in which students build iOS apps, students can choose to build apps in Objective-C or Swift, depending on where they want to explore. Students can work with their personal program coordinator and their mentor to ensure their choices align with their long-term goals. Because of our curriculum’s flexibility, you can complete anywhere from 2% to 70% of the Bloc iOS program in Swift.</p><p>For more information about Bloc’s online iOS bootcamp, review our<a href="https://www.bloc.io/ios-bootcamp"> iOS syllabus</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1096b42fcd19" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ios-os-x-development/should-i-learn-swift-or-objective-c-for-ios-development-1096b42fcd19">Should I learn Swift or Objective-C for iOS development?</a> was originally published in <a href="https://medium.com/ios-os-x-development">iOS App Development</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Simple, Safe, Inflexible.]]></title>
            <link>https://medium.com/newsonthebloc/swift-simple-safe-inflexible-68ff6fa927dc?source=rss-69af151a6812------2</link>
            <guid isPermaLink="false">https://medium.com/p/68ff6fa927dc</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Aaron Brager]]></dc:creator>
            <pubDate>Wed, 07 Jan 2015 20:50:03 GMT</pubDate>
            <atom:updated>2015-02-27T19:11:25.172Z</atom:updated>
            <content:encoded><![CDATA[<p>Swift is Apple’s new succinct, powerful, and safe programming language for writing iOS and Mac apps.</p><p>Just like <a href="https://gist.github.com/getaaron/9fbbaddebd4757724539">the safety from diesel nozzles</a>, seat belts, and the need for two keys to open a safe deposit box, Swift’s safety comes at the expense of flexibility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*_XPeeZjjjwOViCjVlabN4A.png" /><figcaption>Two locks on a <a href="http://content.time.com/time/printout/0,8816,101361,00.html">Sealed Authenticator System</a> safeguard American missile launch controls. There is no single person who can unlock both locks.</figcaption></figure><p><a href="https://twitter.com/mattt">Mattt Thompson</a> alluded to this tradeoff in his NSHipster piece <a href="http://nshipster.com/the-death-of-cocoa/">The Death of Cocoa</a>. As part of the article, Mr. Thompson reviews several parts of the Swift language that are intuitive and expressive and shows how their application is bogged down by reliance on bridging to older Objective-C classes.</p><p>After reading Mr. Thompson’s article, a few students at <a href="http://bloc.io/ios">Bloc</a> (an online coding bootcamp) asked for clarification on the tradeoff between safety and flexibility. This article shows some examples in a bit more detail. It’s aimed at intermediate iOS / OS X developers, or advanced Objective-C developers who haven’t spent a lot of time with Swift.</p><h4>Extending NSDate</h4><p>As an example, let’s take a look at making <em>NSDate</em> a bit… Swiftier. Creating an <em>NSDate</em> is complicated, mostly because dates are complicated. <em>NSDate</em> is a <a href="https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaEncyclopedia/ClassClusters/ClassClusters.html">class cluster</a>, and an instance can be created by other objects like <em>NSDateFormatter</em>, <em>NSCalendar</em>, and <em>NSDateComponents</em>.</p><p>There’s still a primary use case, though, and we’d like it to be a lot easier in Swift:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56fa72fe6f64bc0dc7e12e8164eefed4/href">https://medium.com/media/56fa72fe6f64bc0dc7e12e8164eefed4/href</a></iframe><p>In order to use our ideal syntax, Swift provides the <em>StringLiteralConvertible</em> protocol. Classes which conform to this protocol can implement <em>init(stringLiteral value: StringLiteralType) </em>which initializes an instance of this class using the string. (You also need to implement the two protocols this protocol inherits from — <em>ExtendedGraphemeClusterLiteralConvertible</em> and <em>UnicodeScalarLiteralConvertible</em> — more on that later.)</p><p>In Objective-C, to add methods to an existing class, you’d probably use a <em>category</em>. The equivalent in Swift is called an <em>extension</em>, and it’s described in <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Extensions.html">the documentation</a> like this:</p><blockquote>Extensions add new functionality to an existing class, structure, or enumeration type.</blockquote><p>So you might think you could simply declare conformance to this protocol, and provide implementations in an extension, like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fc404195dcbe05a39eab2cc58037375/href">https://medium.com/media/2fc404195dcbe05a39eab2cc58037375/href</a></iframe><p>But this won’t work, because of Swift’s safety rules. You’re stuck in between a rock and a hard place:</p><ul><li>When you extend <em>NSDate</em> (or any class) with a protocol, you need to guarantee that all subclasses conform to the protocol. In order to do this, the initializer you’re adding has to be marked as <em>required</em>. <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-XID_351">Required initializers</a> guarantee that every subclass implements or inherits that initializer.</li><li>Swift disallows required initializers from being declared in extensions.</li></ul><p>The other option for extending a class’s functionality, of course, is subclassing. Here’s a subclass of <em>NSDate</em>, which conforms to <em>StringLiteralConvertible</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3547c3149699cdd9e18a1b68f245e43/href">https://medium.com/media/d3547c3149699cdd9e18a1b68f245e43/href</a></iframe><p>This class has a singleton date formatter. In the initializer, the date formatter is used to convert the string to the time interval since <em>NSDate</em>’s absolute reference date. Then the interval is used to initialize the <em>NSDate</em>.</p><p>Running this code throws an exception:</p><blockquote>Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[NSDate initWithTimeIntervalSinceReferenceDate:]: method only defined for abstract class. Define -[Dates.SwiftDate initWithTimeIntervalSinceReferenceDate:]!’</blockquote><p>A closer look at the <em>NSDate</em> documentation indicates we’ve subclassed it incorrectly:</p><blockquote>The major reason for subclassing NSDate is to create a class with convenience methods for working with a particular calendrical system. But you could also require a custom NSDate class for other reasons, such as to get a date and time value that provides a finer temporal granularity. If you want to subclass NSDate to obtain behavior different than that provided by the private or public subclasses, you must do these things:</blockquote><blockquote><em>[long list of things you don’t want to do]</em></blockquote><p>Or in other, more cynical words: If you want to subclass <em>NSDate</em>, you must reimplement <em>NSDate</em>.</p><p><em>NSDate</em> is complex to subclass because it’s a <a href="https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaEncyclopedia/ClassClusters/ClassClusters.html">class cluster</a>. And we can’t use an extension, as we saw above. So maybe we picked a bad example. Let’s try extending a simpler class: <em>NSURL</em>.</p><h4>Extending NSURL</h4><p><em>NSURL</em> isn’t as complex as <em>NSDate</em>, but it’s a good candidate for literal convertibles, since it’s often initialized with strings:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27de040e1d8b77edb9351a012a478aff/href">https://medium.com/media/27de040e1d8b77edb9351a012a478aff/href</a></iframe><p>We can’t implement <em>StringLiteralConvertible </em>using extensions for the same reason we couldn’t with <em>NSDate</em>. But <em>NSURL</em> isn’t a class cluster, so let’s try subclassing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9de688b58955eb2ed2979f73c8fb2619/href">https://medium.com/media/9de688b58955eb2ed2979f73c8fb2619/href</a></iframe><p>This subclass takes the string, <em>value</em>, and passes it to NSURL’s designated initializer <em>init(string:relativetoURL:)</em>.</p><p>However, this code won’t compile. NSURL’s designated initializer is a <a href="https://developer.apple.com/swift/blog/?id=17">failable initializer</a> — it might return a URL, or it might return <em>nil</em>. But <em>StringLiteralConvertible</em>’s initializer is non-failable, and non-failable initializers cannot chain to failable initializers. This safety feature prevents non-failable initializers from failing, but it also prevents us from implementing <em>StringLiteralConvertible </em>on NSURL.</p><h4>Suggestions</h4><p>Here are a few ways Apple could improve Swift:</p><ul><li>Allow developers to chain failable and non-failable initializers and handle possible failures themselves</li><li>Allow required initializers in extensions, and require subclasses to implement these initializers (even if they just call <em>super</em>)</li><li>Provide an option for developers to treat certain errors as silence-able warnings</li><li>Don’t use required initializers in literal convertible protocols</li><li>Make Swift open-source so developers can contribute to its development</li></ul><p>I suspect many of these suggestions are being discussed, or in active development.</p><h4>Summary</h4><p>The example in this article — various difficulties implementing <em>StringLiteralConvertible </em>in Swift 1.1 — is just one type of problem you may see. Swift has many great features, among them an expressive and intuitive syntax. These features have built-in safety mechanisms that will improve the stability of iOS and Mac apps. But Swift’s feature set is far from complete, and the combination of incomplete features and aggressive safety measures make Swift less flexible than Objective-C.</p><p>The current inconveniences associated with strict safety may affect a developer’s choice of language for production apps. Those who want more flexibility may be discouraged from Swift, and stick to Objective-C. Those who value succinctness, speed, and safety will use Swift.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68ff6fa927dc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/newsonthebloc/swift-simple-safe-inflexible-68ff6fa927dc">Swift: Simple, Safe, Inflexible.</a> was originally published in <a href="https://medium.com/newsonthebloc">News on the Bloc</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Open Letter to Companies who Partner with Uber]]></title>
            <link>https://medium.com/@getaaron/an-open-letter-to-companies-who-partner-with-uber-7c3a3311d9f0?source=rss-69af151a6812------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c3a3311d9f0</guid>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[uber]]></category>
            <category><![CDATA[politics]]></category>
            <dc:creator><![CDATA[Aaron Brager]]></dc:creator>
            <pubDate>Sun, 07 Dec 2014 21:31:22 GMT</pubDate>
            <atom:updated>2015-03-05T16:50:41.552Z</atom:updated>
            <content:encoded><![CDATA[<p>Uber is a terrific service from a company with a terrible reputation. I had mixed feelings when one of my favorite iOS apps, <a href="http://thetransitapp.com/">Transit</a>, announced they’re supporting Uber. Transit is just one of many apps using the new <a href="https://developer.uber.com/">Uber API</a> to improve their user experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*XCB6qQqW9KjraKS0UG_0dA@2x.png" /><figcaption>Uber arrival times on Transit. Source: <a href="http://thetransitapp.com/blog/did-someone-request-an-uber">Transit App blog</a>.</figcaption></figure><p>This integration allows users to see predicted Uber arrival time along with buses and trains on a map with bicycle-sharing overlays.</p><p>This is a really <a href="http://thetransitapp.com/blog/did-someone-request-an-uber">great innovation for people without cars</a>. The ability to easily compare many forms of transit in one glance is long overdue. But partnering with Uber comes at a cost: Uber restricts your company’s future partnerships, and your brand may be tarnished by Uber’s bad reputation.</p><p>Uber is led by <a href="http://www.institutionalinvestor.com/inside-edge/3402854/uber-silicon-valley-and-sexism.html">sexist and misogynistic executives</a>.</p><p>Uber <a href="http://www.businessinsider.com/is-uber-operation-slog-legal-2014-8">blocks customer access to competitors’ drivers while simultaneously trying to recruit them</a>.</p><p>Uber <a href="http://blog.uber.com/uberimpact">claims their drivers make lots of money</a>:</p><blockquote>UberX driver partners are small business entrepreneurs demonstrating across the country that being a driver is sustainable and profitable. For example, the median income on uberX is more than $90,000/year/driver in New York and more than $74,000/year/driver in San Francisco.</blockquote><p>But a <a href="http://www.slate.com/articles/business/moneybox/2014/10/uber_driver_salary_the_ride_sharing_company_says_its_drivers_make_great.html">research piece by Slate magazine</a> indicates this is extremely unlikely. Drivers have started <a href="http://www.slate.com/blogs/moneybox/2014/09/12/uber_drivers_strike_they_protested_cheap_uberx_fares_uber_backed_down.html">protests and strike threats</a> over compensation.</p><p>Finally, Uber <a href="http://en.wikipedia.org/wiki/Uber_%28company%29#User_privacy">plays fast and loose with your location and travel data</a> with features like “<a href="http://www.engadget.com/2014/11/19/uber-godview-tracking/">God View</a>” and a toothless privacy policy. Uber is also allowed to keep your data forever.</p><blockquote>If you partner with Uber, you’re associating your brand with sexism, anticompetitive behavior, disrespect for user privacy, and… let’s call it “exaggerating” about compensation.</blockquote><h3>How to Fix It</h3><p>Uber is convenient, smart, and well-made, and it’s really great that companies are eager to make it easier for customers to get around. If you’re working on an app with Uber support, or otherwise partnering with Uber, there are a few problems you can help overcome.</p><p>Uber’s treatment of women and workers is deeply concerning. There may be no solution to this aside from not using Uber at all. Consequently, these proposed solutions primarily relate to Uber’s privacy issues and anti-competitive practices.</p><p><strong>Uber blocks apps from supporting their competition.</strong> One solution would be to give consumers a choice about which service to use. This is impossible right now, because <a href="http://techcrunch.com/2014/08/20/uber-api-terms">Uber blocks their partners from using the Uber API if they support competing services</a>. From the terms of service:</p><blockquote>You may not use the Uber API in any manner that is competitive to Uber or the Uber Services, including in connection with any application, website or other product or service that also includes, features, endorses, or otherwise supports in any way a third party that provides services competitive to Uber’s products and services, as determined in our sole discretion.</blockquote><p>As an Uber partner who cares about your customers, you should contact Uber and ask them to remove this stipulation.</p><p><strong>Level the playing field.</strong> Integrate support for Lyft, Sidecar, and other competitors. While Lyft and Sidecar don’t have public APIs for arrival times yet, you can still <a href="http://blog.smallsharptools.com/post/85029854575/opening-lyft">have your app open Lyft or Sidecar.</a> This shows support for paying drivers well: Lyft gives a higher percentage of pay to drivers, and Sidecar allows drivers to set their own rate.</p><p><strong>Clearly indicate what data your app sends to Uber.</strong> Users are nervous about how Uber uses their data. Don’t lump Uber in with other third parties in your privacy policy. Be explicit about what data is sent to Uber and how often it’s sent. Will you send Uber your user’s IP address or other uniquely identifying info? Spell it out.</p><p>The Uber API allows your app to optionally send a unique <em>customer_uuid</em> to their service. Don’t send one, or consider sending a randomly generated one. <strong>If possible, hide your user’s IP address from Uber </strong>by routing API requests through another server.</p><p><strong>Make it easy to opt out.</strong> Some of your users don’t want anything to do with Uber, and they might not want anything to do with you if you don’t allow them to opt out. Most apps with Uber integration offer no way to turn it off. Transit <em>might</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*2laLeC5cjB1lQrk0iztfjA@2x.png" /><figcaption>Screenshot from the Transit App’s settings. Users can hide transportation types, but it isn’t clear if Transit withholds user data from data providers when they’re disabled.</figcaption></figure><p>But even here it’s not clear whether switching Uber off just hides the view, or whether it actually disables sending data to Uber.</p><h3>Summary</h3><p>Uber has grown quickly, and it’s a huge, but very immature, company. Users welcome the innovation, but don’t welcome the terrible things they do.</p><p><strong>If you’re a company</strong> <strong>partnering with Uber</strong>, please publicly request that Uber:</p><ul><li>take steps to end their sexism</li><li>pay their drivers fairly and be honest about how much drivers will profit</li><li>stop their anti-competitive behavior, including blocking Lyft driver access and onerous Uber API terms</li><li>improve their privacy policy by adding data expiration and the ability to opt out of data sharing</li></ul><p><strong>If you’re building Uber integration</strong> <strong>into your app</strong>, make sure you:</p><ul><li>tell your customers clearly what data you’re sending to Uber</li><li>allow your customers to opt out (or even make it opt-in)</li><li>obfuscate customer data you send to Uber’s API</li></ul><p><strong>If you’re a customer</strong> who uses a product with Uber integration, ask for these changes to be implemented or stop using these products altogether.</p><p><a href="https://github.com/getaaron/uber-partners">Here’s a list of Uber partners</a> and their contact information.</p><p><a href="https://twitter.com/getaaron"><em>@getaaron</em></a><em> on Twitter.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c3a3311d9f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leaked: Apple’s 5-year OS X roadmap]]></title>
            <link>https://medium.com/@getaaron/leaked-apples-5-year-os-x-roadmap-aa0993ac7a81?source=rss-69af151a6812------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa0993ac7a81</guid>
            <dc:creator><![CDATA[Aaron Brager]]></dc:creator>
            <pubDate>Fri, 31 Oct 2014 01:00:03 GMT</pubDate>
            <atom:updated>2014-10-31T01:00:03.178Z</atom:updated>
            <content:encoded><![CDATA[<p>Inside sources reveal the names of Apple’s next five Mac operating systems:</p><blockquote>2015 — OS X Compton (10.11)<br>2016 — OS X 90210 (10.12)<br>2017 — OS X Zzyzx (10.13)<br>2018 — OS X The O.C. (10.14)<br>2019 — OS Tenderloin (10.15)</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa0993ac7a81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Some Students Don’t Learn to Code]]></title>
            <link>https://medium.com/newsonthebloc/why-some-students-dont-learn-to-code-fe3bce9e9b6c?source=rss-69af151a6812------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe3bce9e9b6c</guid>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Aaron Brager]]></dc:creator>
            <pubDate>Thu, 25 Sep 2014 19:51:11 GMT</pubDate>
            <atom:updated>2015-02-27T19:04:04.105Z</atom:updated>
            <content:encoded><![CDATA[<h4>Common Roadblocks, and How to Overcome Them</h4><p>At <a href="https://bloc.io/">Bloc</a>, we teach web and mobile app development and design. We teach using a 1-on-1 apprenticeship model, so we get to know students really well. Unfortunately, not all students complete the course, and we’ve learned a lot about why and how students struggle learning to code. This essay explains the primary reasons people have trouble learning, and outlines some possible remedies.</p><p><strong>Just skimming?</strong> See the summary at the end.</p><h3>Learning is Blocked by Frustration</h3><p>Consider this simple loop, written in Ruby, which prints the numbers 1 through 10:</p><pre>i = 1<br>limit = 10<br><br>while i &lt;= num do<br> puts(&quot;Number #{i} of #{limit}&quot;)<br> i += 1<br>end</pre><p>This code is extremely simple to even a junior computer programmer, but can be frustrating to a beginner.</p><p>If you know Ruby, you know there’s a simpler implementation:</p><pre>limit = 10<br><br>1.upto(limit).each do |num|<br> puts &quot;Number #{num} of #{limit}&quot;<br>end</pre><p>But even this can be pretty confusing.</p><p>So, why is it frustrating to someone who hasn’t coded?</p><ul><li>It’s cryptic.</li><li>The symbols used to express specific concepts are unintuitive.</li><li>The difference between <em>(limit)</em> and <em>#{limit}</em>, or between <em>|num|</em> and <em>#{num} </em>may be unclear.</li></ul><p>The student may attempt to reread training materials or documentation to understand the code better. But consider <a href="http://www.ruby-doc.org/core-2.1.3/IO.html#method-i-puts">the documentation on <em>puts</em></a>:</p><blockquote><strong>puts(obj, …) → nil</strong></blockquote><blockquote>Writes the given objects to <em>ios </em>as with IO#print. Writes a record separator (typically a newline) after any that do not already end with a newline sequence. If called with an array argument, writes each element on a new line. If called without arguments, outputs a single record separator.</blockquote><p>What the heck is <em>nil</em>? Or a <em>newline</em>? How is that different from a <em>newline sequence</em>? What’s <em>ios, array argument</em>, or <em>IO#print</em>? Even these basic questions require prior knowledge. A new programmer may Google something like “<em>word in my rails app not showing up right</em>”. That’s not going to yield useful results, because programmers represent words using <a href="https://en.wikipedia.org/wiki/String_(computer_science)"><em>strings</em></a>.</p><p>Attempts to research these questions open the door to more and more questions, and the learner shuts down, drowned in a deluge of information, none of which is needed to understand this basic code.</p><p>“Am I smart enough for this?” learners ask. “Will I <em>ever</em> be able to learn this? Is it too late for me?”</p><p>As perfection is the enemy of the good, so is self-doubt the enemy of learning. Wikipedia’s <a href="https://en.wikipedia.org/wiki/Learning">article on learning</a> nails it:</p><blockquote>Learning is not compulsory; it is contextual. It does not happen all at once, but builds upon and is shaped by what we already know. To that end, learning may be viewed as a process, rather than a collection of factual and procedural knowledge.</blockquote><p>If you’re learning to code, remember that <strong>you don’t need to fully understand everything you’re doing to make progress</strong>. Learning to code doesn’t mean achieving mastery. Do you know more about <em>puts</em> than you did yesterday? If so, you’re learning.</p><p><a href="https://en.wikipedia.org/wiki/The_Devil_is_in_the_detail">The devil is in the detail</a>, they claim. But remember that if you only pay attention to the details, you won’t get the big idea right. Give yourself the freedom to move on to the next task, even if you only understand two thirds of what you’re doing.</p><p>Of course, some students students struggle later on because they rush through things without understanding them. There’s an important balance to strike here, and it’s helpful to revisit old material once you’re more comfortable with the concept.</p><h4>Remedies</h4><ul><li><strong>Learn to Google.</strong> This may seem obvious, but students have asked us easy-to-Google questions thousands of times. Blog and forum posts are typically higher-level than technical documentation, so start with those.</li><li><strong>Work with a Mentor.</strong> It’s challenging to know what’s important and what’s not. Get a friend or hire a mentor to help you filter out the jibber-jabber, and put you back on the right path if you venture into a black hole.</li><li><strong>Learn to Write Down Your Question</strong>. Read Stack Overflow’s <a href="http://stackoverflow.com/help/how-to-ask"><em>How do I ask a good question?</em></a>. Take a stab at writing a <a href="http://stackoverflow.com/help/mcve"><em>Minimal, Complete, and Verifiable example</em></a>, even if it’s imperfect, and even if you never send your question to anyone. Explain what you’re <strong>expecting</strong>, what <strong>actually happened</strong>, <strong>how they differ, </strong>and <strong>why you think that is</strong>. There are two benefits to writing down a question. First, this process frequently helps students figure out the answer on their own. Second, if students don’t figure it out, they have a well-written question to post on Stack Overflow or send to a mentor.</li></ul><p>By following this advice, you should be able to avoid the frustrating experience of feeling like you’re not learning. <strong>Don’t doubt yourself</strong>. If you can do basic math, read, and write, you can learn to code.</p><h3>There’s Not Enough Time</h3><p>Most students who don’t complete the course aren’t putting in enough time. Learning a new skill is challenging, and you should be prepared to spend some time on learning every day. Learning comes in a variety of forms, and repetition is important. For <a href="https://bloc.io/">Bloc</a> students, this can include:</p><ul><li>Reading training material</li><li>Reading sample code</li><li>Writing code to complete assignments</li><li>Meeting with their mentor</li></ul><p>This is a rigorous process. If you’re only dedicating 2 or 3 days a week to it, you’re less likely to complete the course than a student who works a little bit every day. Work on learning at least a little bit every day.</p><p>There are two more suggestions, nether of which are programming-specific. First, remember to <a href="https://en.wikipedia.org/wiki/Sleep_debt">get enough sleep</a>. There are significant data that show:</p><ul><li>Sleep loss has a cumulative effect</li><li>Inadequate sleep makes it very difficult to learn new skills</li></ul><p>In addition to the scientific data, our own anecdotal experience supports this as well: students often report understanding difficult concepts with stunning lucidity, which they previously struggled with, after a good night’s sleep.</p><p>Finally, budget some flex time for schedule variations. It’s important to spend time every day learning. If a family member has health issues or a college friend is in town for one day, make sure you still have some time to spend on learning to code.</p><h4>Remedies</h4><ul><li><strong>Spend enough time.</strong> You should spend at <em>least</em> 3 hours a day when developing new skills. Ideally, you’d dedicate more.</li><li><strong>Get 8 hours of sleep every night.</strong> People who slept 6 hours a night for 10 days had <a href="https://en.wikipedia.org/wiki/Sleep_debt#cite_note-3">similar results</a> to those who were completely sleep deprived for 1 day.</li><li><strong>Plan for the unplanned.</strong> Make sure you’ll be able to handle last-minute changes in your schedule.</li></ul><p>By following this advice, you’ll be able to dedicate a sufficient amount of time to learning while maintaining a work/life balance.</p><h3>Incorrect Expectations</h3><p>Some students join our program with incorrect expectations. For example:</p><ul><li>Students underestimate how much work learning to code is</li><li>Students sometimes miss skills that are required to learn. You should have an understanding of basic algebra (if <em>70 = 2x + 10</em>, can you figure out what <em>x</em> is?). You should also have good reading and writing skills.</li></ul><p>Before you learn to code, it’s worth your time to connect with a mentor or experienced developer and discuss what you hope to learn along with your current abilities.</p><h3>Summary</h3><p><strong>Don’t get frustrated by learning. </strong>Both code and documentation are difficult to read and absorb, especially as a beginner. Use summaries like blog and forum posts alongside documentation to help you boil down complex concepts to their essence. Work with a mentor. Learn to read critically. Learn to write clear, concise questions when you’re struggling with a concept, even if you never show your writing to anyone.</p><p><strong>Manage your time.</strong> Make a rigorous schedule. Work on coding every day. Sleep for 8 hours every night. Build some flexibility into your schedule.</p><p><strong>Understand what’s required.</strong> Talk to a mentor or experienced developer about your current skill set and decide if there’s something new you should pick up. Make sure you have a reasonable understanding of the complexity of the material, and what skills you hope to build.</p><p>If you’re interested in learning to code or design web apps, iOS apps, or Android apps 1-on-1 with a mentor and a rigorous curriculum, check out <a href="https://bloc.io/">Bloc</a>.</p><p><a href="http://twitter.com/getaaron">Tweet me</a> if you have any ideas for expanding this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe3bce9e9b6c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/newsonthebloc/why-some-students-dont-learn-to-code-fe3bce9e9b6c">Why Some Students Don’t Learn to Code</a> was originally published in <a href="https://medium.com/newsonthebloc">News on the Bloc</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS 8 Development Tips for iPhone 6 and iOS 8]]></title>
            <link>https://medium.com/ios-os-x-development/ios-8-development-tips-for-iphone-6-and-iwatch-1c772554ffe0?source=rss-69af151a6812------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c772554ffe0</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[iphone]]></category>
            <dc:creator><![CDATA[Aaron Brager]]></dc:creator>
            <pubDate>Tue, 09 Sep 2014 19:10:26 GMT</pubDate>
            <atom:updated>2015-04-02T18:50:58.251Z</atom:updated>
            <content:encoded><![CDATA[<h2>iOS Development Tips for iPhone 6 and iOS 8</h2><p>With thousands of <a href="https://developer.apple.com/library/prerelease/ios/releasenotes/General/iOS80APIDiffs/index.html#//apple_ref/doc/uid/TP40014455">API changes in iOS 8</a>, developers have been hard at work updating their apps to support the latest version of iOS. Many hope to have their apps ready in the App Store when iOS 8 launches on September 17.</p><p>For those of you still working through the changes, here are some tips for your development on iPhone 6 and iOS 8.</p><blockquote>This post is intended for beginner and intermediate developers. Code samples are in Objective-C, but can be rewritten in Swift.</blockquote><blockquote>This post will be updated as more information becomes available.</blockquote><h3>iPhone and iPad screen sizes</h3><p>In the past, we’ve only had to deal with three point resolutions on iOS:</p><ul><li>320 x 480 (iPhone 4s and earlier)</li><li>320 x 568 (iPhone 5 and later)</li><li>768 x 1024 (iPad)</li></ul><p>In addition to that, there were only two pixel densities: <em>regular</em> (1x) and <em>Retina</em> (2x).</p><p>Now there are two additional point sizes to consider:</p><ul><li>375 x 667, with 2x Retina pixel density, for iPhone 6</li><li>414 x 736, with 3x Retina pixel density, for iPhone 6 Plus (<a href="http://stackoverflow.com/q/25755443/1445366">some scaling is involved</a>)</li></ul><p>Can your app handle all of these resolutions?</p><blockquote>“I can take it. The tougher it gets, the cooler I get.”<br>Richard M. Nixon</blockquote><h3>Which Display is This?</h3><p>If you’re working on an existing app, you might be checking if you’re on an iPad or iPhone by checking the view’s width:</p><pre><em>if (CGRectGetWidth(self.frame) == 320) {<br>    /* Do something for iPhone */<br>}</em></pre><p>This test will no longer produce the results you’re looking for.</p><p>Another approach is testing the device idiom:</p><pre><em>if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)) {<br>    /* Present a UITableViewController subclass */<br>} else {<br>    /* Present a UISplitViewController subclass */<br>}</em></pre><p>This <em>may</em> produce the results you want, but <em>probably</em> won’t. It won’t natively take advantage of all of your screen real estate, especially in landscape mode.</p><p>Instead, consider that with iPhone 6 Plus, you’ll likely want an iPhone-style UI in portrait, and an iPad-style UI in landscape.</p><p>For example, suppose you have an award-winning app, <strong>FireStarter</strong>, and it looks like this in landscape on iPad:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KZmfnKU0u7fR1ie3MicEbA.png" /><figcaption>Former US president Richard Nixon, presented in landscape orientation on iPad, clenches his fist in a decisive show of fearless leadership.</figcaption></figure><p>If your code only checks the device idiom, here’s how your user interface would look on iPhone 6 Plus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*wajnpuFwb58xOBPok08WsA.gif" /><figcaption>Nixon established the <a href="https://en.wikipedia.org/wiki/United_States_Environmental_Protection_Agency">Environmental Protection Agency</a> (EPA) in 1970.</figcaption></figure><p>Obviously, users will be frustrated if you allocate 100% of their 5.5 inches of Retina HD screen real estate to listing five items on a table. Instead, we want it to look more <em>iPad-esque:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwj4IzT-QKOJzV_q6XFsOQ.png" /><figcaption>Rumors indicate that OS X 10.11 will be named “OS X <a href="http://www.yorbalindahistory.org/timeline.html">Yorba Linda</a>” after Nixon’s birthplace</figcaption></figure><p>To implement this yourself, the easiest way is to learn about iOS 8&#39;s Split View Controller behavior.</p><h3>iOS 8 Split View Controller and Size Classes</h3><p>Since the dawn of time, <em>UISplitViewController</em> has only been available on iPad. Starting with iOS 8, the Split View Controller now works on iPad and iPhone.</p><h4>Size Classes</h4><p>To accommodate these different devices, iOS 8 introduced <strong>size classes</strong>. These are intended to replace both <em>UIInterfaceOrientation </em>and <em>UIUserInterfaceIdiom. </em>There are four:</p><ul><li>Horizontal Regular</li><li>Horizontal Compact</li><li>Vertical Regular</li><li>Vertical Compact</li></ul><p>In iOS 8, these can be accessed on a view controller’s <em>traitCollection</em> property, and <em>traitCollectionDidChange:</em> will get called if it changes, for example on device rotation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3sbKb2NZUf0WFHB-kgkaUQ.png" /><figcaption>iOS devices and their size classes</figcaption></figure><p>Full-screen view controllers on iPad are always “regular”. On iPhones before iPhone 6, the vertical dimension is always “compact” and the horizontal dimension is only “regular” in portrait mode. With the larger iPhones introduced today, the vertical dimension will now be “regular” in landscape mode.</p><p>By adopting size classes, you can provide your normal iPhone UI in portrait, and an iPad-like UI in landscape on iPhone 6. For example, if you’re making a cookbook app, you might show a unit conversion widget for “regular” but hide it for “compact”:</p><pre>if (self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact) {<br>    /* Hide the extra details */<br>} else if (self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular) {<br>    /* Show the extra details */<br>}</pre><p>You can override the trait collection for a view controller. This would allow you to use the “regular” interface on smaller iPhones in landscape.</p><h4>Split View Controller’s Use of Size Classes</h4><p>If your app has a standard master-detail UI, you can simplify a lot of this by just using a split view controller instead of writing the logic yourself.</p><p>Here’s how it works:</p><ul><li>If the controller’s traits include <strong>horizontal regular</strong>, the two controllers are presented side-by-side, like in the above screenshot.</li><li>If the controller’s traits include <strong>horizontal compact</strong>, the primary view controller is displayed, and the secondary view controller is pushed or popped as needed.</li></ul><p>There are some exceptions to this behavior noted in the documentation. This behavior can also be customized by implementing a <a href="https://developer.apple.com/library/prerelease/iOS/documentation/UIKit/Reference/UISplitViewControllerDelegate_protocol/index.html#//apple_ref/occ/intf/UISplitViewControllerDelegate">UISplitViewControllerDelegate</a> object and by setting the <a href="https://developer.apple.com/library/prerelease/iOS/documentation/UIKit/Reference/UISplitViewController_class/index.html#//apple_ref/occ/instp/UISplitViewController/preferredDisplayMode">preferredDisplayMode</a> property. For example, you might want to set this property to <a href="https://developer.apple.com/library/prerelease/iOS/documentation/UIKit/Reference/UISplitViewController_class/index.html#//apple_ref/c/econst/UISplitViewControllerDisplayModePrimaryOverlay">UISplitViewControllerDisplayModeOverlay</a> if you want the iPad-style popover on iPhone.</p><h3>New Rotation Behavior in iOS 8</h3><p>iOS 8 deprecates all rotation methods in favor of one: <em>viewWillTransitionToSize:withTransitionCoordinator:</em>. This method is called on a view controller when the size of its view is about to change. This can happen for many reasons, for example:</p><ul><li>The user rotated the device</li><li>The status bar got larger (for example, during Voice Memo recording or an incoming phone call)</li><li>A higher-level view controller resized this view controller’s view</li></ul><p>If you’re using basic auto-layout and your constraints don’t need to be updated, you may not need to implement this method at all. If you are using frame-based layout, or need to perform some calculations to update auto-layout constraint constants, this method is the place to do it.</p><p>A typical implementation will call <em>super</em> and then tell the animation coordinator what to change:</p><pre>-(void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id&lt;UIViewControllerTransitionCoordinator&gt;)coordinator {<br>    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];</pre><pre>    [coordinator animateAlongsideTransition:^(id&lt;UIViewControllerTransitionCoordinatorContext&gt; context) {<br>        /* Reorganize views, or move child view controllers */<br>    } completion:^(id&lt;UIViewControllerTransitionCoordinatorContext&gt; context) {<br>        /* Do any cleanup, if necessary */<br>   }];<br>}</pre><p>The animation coordinator will animate the changes you specify along with all of the others at the same time.</p><h3>HealthKit and Apple Watch</h3><p>Apple Watch contains a bunch of sensors like an accelerometer, a heart rate sensor, and more. iPhone 6 also contains new sensors that can more accurately measure distance and elevation. Health data is stored in iOS 8&#39;s new Health app and it can also be accessed in your app via HealthKit.</p><p>Apple has provided excellent <a href="https://developer.apple.com/library/prerelease/ios/samplecode/Fit/Introduction/Intro.html#//apple_ref/doc/uid/TP40014583-Intro-DontLinkElementID_2">sample code</a>, <a href="https://developer.apple.com/videos/wwdc/2014/?id=203">a WWDC video</a> (<a href="http://asciiwwdc.com/2014/sessions/203?q=healthkit">transcript</a>; <a href="http://devstreaming.apple.com/videos/wwdc/2014/203xxh9oqtm0piw/203/203_introducing_healthkit.pdf?dl=1">PDF</a>), so we‘ll just cover the basics here.</p><p>If you’ve used Apple’s other permissions-based APIs, though, it should look familiar. Getting permission is asynchronous and block-based:</p><pre>self.healthStore = [[HKHealthStore alloc] init];</pre><pre>if ([HKHealthStore isHealthDataAvailable]) {<br>    NSSet *writeDataTypes = /* info you want to write */<br>    NSSet *readDataTypes = /* info you want to read */</pre><pre>    [self.healthStore requestAuthorizationToShareTypes:writeDataTypes readTypes:readDataTypes completion:^(BOOL success, NSError *error) {<br>        if (success) {<br>            dispatch_async(dispatch_get_main_queue(), ^{<br>                /* Do something with the user’s health info */<br>            });<br>        } else {<br>            /* Permission denied, or some other error */<br>        }<br>    }];<br>}</pre><p>Some information can be obtained by simply asking the health store:</p><pre>NSError *err;<br>NSDate *dateOfBirth = [self.healthStore dateOfBirthWithError:&amp;err];<br><br>if ([dateOfBirth isEqualToDate:self.birthday]) {<br>    /* Order Birthday Cake 🎂 */<br>}</pre><p>More complex information, including how data has changed over time, can be obtained with different query objects, like <em>HKSampleQuery</em> and <em>HKAnchoredObjectQuery</em>. Also interesting is <em>HKObserverQuery</em>, which will inform your app in real-time as new data is recorded from the sensor.</p><p>These queries can help you motivate your customers to live a healthier lifestyle by showing them how far they’ve come.</p><blockquote>“Only if you have been in the deepest valley, can you ever know how magnificent it is to be on the highest mountain.”<br>Richard M. Nixon</blockquote><h3>Apple Pay (NFC Payments)</h3><p>Some merchants already have built-in support for Apple Pay in their app:</p><ul><li>Target</li><li>Groupon</li><li>Uber</li><li>Panera</li></ul><p>Here’s the <a href="https://developer.apple.com/apple-pay/">Apple Pay third-party API documentation</a>, which also lists some supported payment providers. Apple Pay requires that you have a payment processor or gateway, just as if you were taking a credit card. You need to set up certificates and entitlements through the developer portal, and conform to these rules:</p><blockquote>Apps using Apple Pay must provide all material purchase information to the user prior to sale of any good or service or they will be rejected</blockquote><blockquote>Apps using Apple Pay must use Apple Pay branding and user interface elements correctly and as described in the Apple Pay Human Interface Guidelines or they will be rejected</blockquote><blockquote>Apps using Apple Pay as a purchasing mechanism may not offer goods or services that violate the law of any territory in which the good or service will be delivered and may not be used for any illegal purpose</blockquote><blockquote>Apps using Apple Pay must provide a privacy policy or they will be rejected</blockquote><blockquote>Apps using Apple Pay may only share user data acquired via Apple Pay with third parties when provided to facilitate or improve delivery of goods and services or to comply with legal requirements</blockquote><p>Your app specifies the contents of the payment:</p><pre>PKPaymentRequest *request = [[PKPaymentRequest alloc] init];<br>// configure the request</pre><p>Present a payment sheet:</p><pre>PKPaymentAuthorizationViewController *paymentVC = [[PKPaymentAuthorizationViewController alloc] initWithRequest:request];<br>paymentVC.delegate = self;</pre><pre>[self presentViewController:paymentVC animated:YES completion:nil];</pre><p>If the user approves the payment, your app receives a payment token. Use your payment gateway’s API to authenticate, and call the completion handler once you’re done.</p><pre>- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus status))completion {</pre><pre>    /* authorize the payment with your provider */</pre><pre>    if (/* it worked */ &amp;&amp; completion) {<br>        completion(PKPaymentAuthorizationStatusSuccess);<br>    } else {<br>        /* handle other cases */<br>    }<br>}</pre><p>Dismiss the payment controller and inform your users of their order status, approximate shipping time, how to check order status, etc.</p><h3>Additional Resources</h3><p>Gaurav Tomar put together an excellent <a href="http://gauravstomar.blogspot.com/2014/06/view-controllers-in-ios-8-quick-review.html">overview of view controller changes in iOS 8</a>. The WWDC video <a href="https://developer.apple.com/videos/wwdc/2014/?include=216#216">Building Adaptive Apps with UIKit</a> is also incredibly helpful (<a href="http://asciiwwdc.com/2014/sessions/216">transcript</a>; <a href="http://devstreaming.apple.com/videos/wwdc/2014/216xxcnxc6wnkf3/216/216_building_adaptive_apps_with_uikit.pdf?dl=1">PDF</a>).</p><p>Shinobi Controls has <a href="http://www.shinobicontrols.com/blog/posts/2014/08/04/ios8-day-by-day-day-12-healthkit">a thorough introduction to HealthKit</a> that describes the different objects, along with sample code. (If you have a health app, you might want to look at their beautiful graph and chart controls too.)</p><p>Stripe has <a href="https://stripe.com/docs/mobile/ios">some sample code </a>available for implementing Apple Pay.</p><p>If you’re just getting started with iOS development and want to amp up your learning, see my <a href="http://blog.bloc.io/ultimate-guide-to-ios-developer-bootcamps/">Ultimate Guide to iOS Developer Bootcamps</a>. Also, Bloc (where I work) is <a href="http://try.bloc.io/iphone">giving away a free iPhone 6</a> to developers who register this month.</p><p>More information about Richard Nixon is available on <a href="http://www.whitehouse.gov/about/presidents/richardnixon">the White House’s presidential history page</a>.</p><h3>About Me</h3><p><a href="http://twitter.com/getaaron">Aaron Brager</a>, the <a href="http://bloc.io/iOS">iOS Director at Bloc</a>, makes iOS apps, and enjoys word play like puns and portmanteaus. He enjoys following the creative output of other Aarons, including <a href="http://www.bignerdranch.com/about-us/nerds/aaron-hillegass.html">Aaron Hillegass</a>, <a href="http://www.builtinchicago.org/blog/5-chicago-ctos-you-should-know-part-2-aaron-rankin-sprout-social">Aaron Rankin</a>, and <a href="https://en.wikipedia.org/wiki/Aaron_Sorkin">Aaron Sorkin</a>. He also enjoys playing chess, although he frequently loses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c772554ffe0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ios-os-x-development/ios-8-development-tips-for-iphone-6-and-iwatch-1c772554ffe0">iOS 8 Development Tips for iPhone 6 and iOS 8</a> was originally published in <a href="https://medium.com/ios-os-x-development">iOS App Development</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>