S Link
iOS Learning Weekly Newsletter
Nice free newsletter focused on learning development for the Apple ecosystem (iOS, watchOS, and OS X). iOS Learning Weekly is a hand curated newsletter full of links to amazing content to help new developers as well as seasoned developers stay up to date with all of the great learning resources, tools, code, and articles on the web each week. You can subscribe through email or Safari push notification.
Totem Training - Onsite iOS Developer Training Summer Promotion
Free iPod Touch: 6th Generation for every student attending one of our onsite events!
Swift Around the Web
Genericizing Code
I LOVE these simple guidelines from @ericasadun on when to use protocols and generics in your Swift code. One big thing here is to do it as the need comes up vs over-genericizing your code right away just because it's the cool thing to do (remember YAGNI!).
My personal favorite tip (maybe because I keep forgetting this with Swift) has to do with conforming at the highest possible level:
"When adding protocol conformance and default implementations, do so at the highest possible abstraction that still makes sense. Instead of adding separate adoptions for, for example, Int and String, check whether there is a unifying concept that can be introduced at a common protocol they both already adopt."
Defeating the Anti-Pattern Bully 💥 Singletons
I posted @allonsykraken's initial blog post on Singletons - The Right Way to Write a Singleton - when it came out, and some of the feedback was very similar to @ashfurrow's reaction: "I was expecting an empty page with NO in giant letters".
While that's funny, and of course Singletons are an anti-pattern that shouldn't be over-used, unfortunately, the Cocoa framework itself suggests we use Singletons for some things - as in the case of expensive NSFormatters. This post covers when it's ok / necessary to use a singleton and how to refactor your code to NOT use common singletons we think we can't live without. A great balance!
Coding
Customizing UIKit appearance using protocols #ProtocolUI
A very interesting way of using Protocols for styling your UIs. I don't think I'm there yet - seems like too much overhead, but it's a cool idea I'd like to think about more. Here is the source code.
Using Guard In Unit Tests
Although I know that horrible if statements is the correct way to deal with optionals in tests, I'll be honest and say that usually I just go ahead and force unwrap them. Luckily Quick deals a lot better with optionals than XCTest, making this a lot less of a headache. So when I saw how much simpler testing is with guard
in this blog post, it made me very happy. Can't wait for the Xcode 7 GM!
Design
Best. Button label. Ever. Note that it’s also the *only* button :)
I'm scared to press this button... So good!
Other Cool Stuff
What Happens When Your Brain Says You Don't Exist
For those of you who don't know, I was a psychology major in college. I love learning about the mind, and especially learning about how the brain works from stories of people with extreme neurological conditions - such as people who are convinced they don't exist!
If you're interested in more paradoxical tales after listening to this podcast, I highly recommend one of my favorite psychology books - An Anthropologist On Mars: Seven Paradoxical Tales by Oliver Sacks, an incredible neurologist who has an amazing gift for storytelling.
In Case You Missed It
iOS: The One Weird Trick For Testing View Controllers in Swift
I’ve been testing View Controllers in Swift for the past year, but for some reason, last week all my tests would just randomly start failing due to some type of timer / race condition issues. Turns out, I was setting up my View Controller tests incorrectly...
After writing this post, I got A LOT of feedback and learned a ton! Thanks everyone who helped me understand this more. I added the feedback as updates in this post. To learn more, also make sure to read @tomkowz follow up blog post: UIViewController’s view loading process demystified.
iOS: A Beautiful Way of Styling IBOutlets in Swift
@jesse_squires tweeted an amazing Swift tip last week: "Use didSet on your IBOutlets to configure views instead of cramming code into viewDidLoad. Much cleaner. Still called only once."
This is so simple and elegant, but why didn't I think of this?!!!! As soon as I saw this, I knew I had to write it down so it lasts beyond just a tweet.
Videos
Humanities x Technology
An absolutely beautiful talk by @ashleynh approaching an important topic we, as developers, lose sight of a lot - the HUGE importance of humanities in what we do. Warning: you might cry!
Playgrounds Are for Kids: Teaching Programming in Swift
I got to see an earlier version of this talk at CocoaConf DC this year, and I've been bringing it up ever since. Really LOVE the idea behind the Turtle Playground! Really glad there is now a video version of this talk I can point others to.
Functional Voodoo
[Video] Object-Oriented Functional Programming: The Best of Both Worlds!
I initially watched this talk live at NSMeetup and I remember having a few HUGE breakthroughs in my understanding of functional programming as a result. Thanks for the great explanations of complex topics Saul Mora! I'm glad there is now a video version of this talk. Highly recommend watching it!
WATCH
watchOS 2: The Power of Animations
Great tutorial for implementing animations on the Apple Watch. Don't worry, it's a lot like animating UIViews in iOS (animateWithDuration:animations
and everything!)! Here are the properties you can animate:
- opacity
- alignment
- width and height
- background color
- color and tint color
Have fun (but not too much 😁)!
Redesigning the Apple Watch UI
The most important takeaway from this post: the hierarchy of use on the Apple Watch is
- Notifications
- Glances
- Apps
Too bad the Apple Watch UI is not designed with this in mind (yet). But of course your app can be!
Podcasts
Swiftly Flattening a Map
There's definitely a void in the Swift Podcast space, so I was excited to discover [Podcast sharedInstance] this week! And I was pleasantly surprised to hear my own name in it 😊. Great discussion and clever name (see my thoughts on singletons above)!
Swift Code
Conformances and Associated Types - Source code follows the conformance list (blog post here)
RazzleDazzle - A simple keyframe-based animation framework for iOS, written in Swift. Perfect for scrolling app intros.
LiterateSwiftGUI - LiterateSwift is a (GUI) tool to edit your literate swift files.
JazzHands - A simple keyframe-based animation framework for UIKit. Perfect for scrolling app intros.
ParksAndRecreation - Various Swift playgrounds, for fun and for profit.
Business
Falsehoods Programmers Believe
The name one especially stood out to me, as I read this powerful post recently: My name is only real enough to work at Facebook, not to use on the site. And there are definitely worse ones not even listed here - like assuming that everyone with a title Dr is male.
When designing systems, assumption like these are built into our programs as obvious, but they can have really far-reaching consequences for the people they impact. Really question your built-in assumptions! You (and I!) can start by reading the articles listed here.
Why building a successful blog takes a long time
This is a very beautifully written post about the long road to success and the level of persistence necessary as there are no clear signs of success along the way. I know it's about blogging (and I can totally relate on that point!), but it no-doubt applies to anything you do. Remember, there is rarely such a thing as an overnight success, yet the media over-fantasizes about it. Refreshing to have someone talk honestly about what it's really like.
Swift Thoughts
This week I've been thinking about View Controllers. Yes, View Controllers! While I haven't found many issues with them in Objective-C, I feel like I'm fighting them constantly in Swift, especially when it comes to working with dependency injection (having to use var vs let) and optionals (having to use explicitly unwrapped optionals for mandatory variables).
I'm not sure @chriseidhof's Functional View Controller is the right answer for us in the masses, but I would love to see a more functional re-write of UIViewController in the future which makes it easier to inject variables via a convenience initializer.
But to leave you on a happier note, the exciting news from this week is that there are almost 1000 Swift Pods on CocoaPods ! 🎉🍦🎈