S Link
Learn Something New Each Week with NSScreencast!
NSScreencast offers weekly, bite-sized videos on iOS & Mac development. On the site, you’ll find over 220 episodes of members-only content. Each episode covers a single topic and is typically 10-20 minutes long. For subscribers of This Week in Swift, we have a special discount of 30% off for 3-months! Sign up here...
Work on a Better Stack!
On Hired, iOS engineers typically get 5+ job offers in 1 week. Find that new opportunity you've been craving and get access to 3,500+ companies instantly.
Swift Around the Web
Common Initializer Patterns in Swift
Interesting solution for when you need to initialize a variable with another variable that needs to be initialized first - a super frustrating problem in Swift. Not sure how comfortable I feel about this solution, but it seems better than other things I've done (including making something a var instead of a let just for this reason).
Coding
Implicitly Crashing Optionals
Really great point on making sure your Objective-C headers are audited for nullability before you import them into Swift 😬
Going with the flow
Just the other day, I wanted to do a Collection View that has a restrained number of rows and columns. It was a lot more difficult than it should be and super frustrating. Good overview of all the components in a collection view and hey, a free playground!
Design
How Technology Hijacks People’s Minds — from a Magician and Google’s Design Ethicist
With great power, comes great responsibility.
Other Cool Stuff
"I tracked the frequency, duration, intensity, and cause of my crying for 18 months"
Fascinating and inspirational data analysis from @personifiedself. Already thinking of my personal habits to track like this!
In Case You Missed It
Refactoring to:
As it's getting closer to WWDC, I've been thinking a lot about the final things I want to learn in the "downtime" until everything changes and I get overwhelming with all the new things. I decided to focus on improving my Refactoring / Architecture Design game by reading Refactoring to Patterns (affiliate link). I'm blogging about the parts I like:
Swift: Configuring a Constant Using Shorthand Argument Names
It's a common pattern in Swift (and a really nice one!) to configure constants right when they are initialized in a closure vs later on in a viewDidLoad or another such method... but it can get awkward!
Videos
Keep Calm and Type Erase On, with Gwendolyn Weston
Mind-blowing presentation from @purpleyay. Didn't realize I didn't know what a type actually was 😰 I'll have to think about the use-case for this some more! Definitely a good and Swifty trick to keep in mind...
Building APIs in Swift on Vimeo
Watch @dantoml build a Todo List API in Swift live on stage 😅 Super excited to hear them speak at try! Swift NYC live in September!!!
Swift Evolution
Trailing commas, open source, and community participation
Amazing analysis of the Swift Evolution process by @ericasadun:
"Unless you’re willing to participate in the Swift Evolution process and speak up for or against proposals, the outcomes may not reflect your specific development needs. The best arguments for or against a proposal are real world code, measurements of use in public and private libraries, and pragmatic use-cases that express why a proposal should be adopted or not. Swift language changes should fix real problems and must be demonstrated with real data."
SE-0094 [ACCEPTED]: Add sequence(first:next:) and sequence(state:next:) to the stdlib
This proposal introduces sequence(first:next:)
and sequence(state:next:)
, a pair of global functions that return (potentially-infinite) sequences of lazy applications of a closure to an initial value or a mutable state.
Example:
for x in sequence(first: 0.1, next: { $0 * 2 }).prefix(while: { $0 < 4 }) {
// 0.1, 0.2, 0.4, 0.8, ...
}
for view in sequence(first: someView, next: { $0.superview }) {
// someView, someView.superview, someView.superview.superview, ...
}
Swift Code
- Cacao - Pure Swift Cross-platform UIKit (Cocoa Touch) implementation (Supports Linux)
- expanding-collection - ExpandingCollection is a card peek/pop controller
- LeeGo - Declarative, configurable & highly reusable UI development as making Lego bricks.
- Scrollable-GraphView - An adaptive scrollable graph view for iOS to visualize simple discrete datasets. Written in Swift.
- MessageKit - Eventually, a Swift re-write of JSQMessagesViewController. Good project to start contributing to if you're looking to get involved in a popular open source project at the start!
- EPSignature - Signature component for iOS in Swift
Swift Thoughts
Last week, in an initial attempt to redesign the try! Swift NYC website, I got ambitious and wanted to do it in Swift. I tried out Vapor and was pleasantly surprised by how simple it was to follow their documentation to launch a "Hello, World" program onto Heroku. It was seriously amazing!
But in the end, I found the server-side Swift ecosystem a bit too distributed and hard to figure out the answers just by Googling - which is expected at this point. And of course, it requires Swift 3.0, which is not out yet.
I ended up leaving my site redesign to an expert who pointed out that it can be done as a simple static page, so nothing fancy was necessary. Still, feeling the future was magical.
Thanks to all the devs out there making server-side Swift a reality 👏