Swift Around the Web
Weak and Unowned References in Swift
I'll be the first to admit that I've been using weak and unowned references wrong in Swift, especially since the difference between weak and unowned are just not that easy to understand (all I know is that unowned sometimes causes an unexpected crash!). Thanks @allonsykraken for providing such an easy-to-follow explanation with great examples!
Personal Note: I encouraged @allonsykraken to start a blog just so he would write this article 😁! And of course I have additional requests, including When to Use Implicitly Unwrapped Articles and more.
Introducing Protocol-Oriented Programming in Swift 2
So the Protocol-Oriented Programming in Swift WWDC Session was incredible but you're left wanting more. This is a simple and practical tutorial on getting started with Protocol Extensions in Swift 2.
Coding
iOS 9
Whoa! I didn't even know about String Transformations. So cool! This is a really detailed overview with great code examples of many under-the-radar changes in iOS 9 - a lot of them I didn't even know about in iOS in general! In other words, you'll learn A LOT from reading this!
Practical Swift: pages generator - build once, use many
"In the real world, at some point, we all have to deal with data that is fetched from a backend service, page by page. It's called paging. Everybody does this! Nothing to be ashamed of ;-) Here is one of the ways in which a Swift pattern (well, not specific to Swift, but visible in Swift) can be used to build a neat solution that allows me to fetch data in chunks and display it in the application."
Apple News
Xcode 7 beta 2 Now Available
Xcode 7 beta 2 if officially out 🎊🎉💥!!! With a lot of exciting features, including using enum cases with payloads as functions and referencing initializers like static functions. View the release notes here or check out @xenadu02's no-login-required Swift 2, Beta 2 summary. Oh yeah, and you can finally subclass generic classes for a specialized type!
Design
Apple Watch Icon Gallery
It's nice to look at the Apple Watch icons in full size here vs the usual squinting on the actual watch!
Other Cool Stuff
How do mosquitos deal with getting hit by raindrops?
"And here’s a puzzle. Raindrops aren’t mosquito friendly. If you’re a mosquito darting about on a rainy day, those drops zinging down at you can be, first of all, as big as you are, and, more dangerously, they’re denser. Water is heavy, so a single raindrop might have 50 times your mass, which means that if one hits you smack where it hurts (between your wings) … … you should flatten like a pancake..." Thanks @mscccc for tweeting this!
In Case You Missed It
iOS: An Optional vs Empty Data Source in Swift
So here is a common scenario in iOS development. You're loading a Table View with data from an API. Initially the Table View is blank, since you're still fetching the data, but very soon (hopefully) the data is fetched and the table view is reloaded as it is meant to be. The issue in Swift is how to represent the data when it is initially blank.
iOS: Using the Wrong dequeueReusableCellWithIdentifier!
For dequeuing table view cells, I’ve been using the dequeueReusableCellWithIdentifier:
method for a while now. I guess it just auto-completed for me one time in Objective-C and, since it was shorter than the other auto-completed method – dequeueReusableCellWithIdentifier:forIndexPath:
, I just kept using it without thinking much about it. This presented a problem for me in Swift with optionals...
Videos
WWDC 2015 Swift Panel Discussion
A Swift look forward (and back) with @chriseidhof, @ayanonagon, @ashfurrow, @nnnnnnnn, @jeffhui, and me - moderated by @simjp!
Ash Furrow: Teaching and Learning
I keep forwarding this video to anyone who expresses even a slight interest in starting a blog, so I have to include it here! This is @ashfurrow's incredibly inspirational talk on why you should share what you're learning from UIKonf 2015. Watch it!
P.S. If you're super impressed by Ash's talk (like I was), take a look at his personal techniques for public speaking. I've personally used some of these tips in my last talk and it went really well!
Books
Playground Secrets and Power Tips 2nd edition
I can't think of anyone else in the world besides the Apple Engineers building Swift Playgrounds who have more expertise on the subject than Erica Sadun. If you're doing anything cool with playgrounds (I'm looking at you educators!), make sure to read this book.
WATCH
Lazy WatchKit tables
One HUGE issue with WatchKit is that it's very slow. And it's definitely not efficient to load all your data at once. @radexp discusses the architecture for lazy loading your data and having a button for the user to load more.
By using this technique, "In one extreme case (100 table rows), I’ve seen an improvement of a whopping 8 seconds in initial load time thanks to lazy loading (and, to lesser extent, view model diffing)." - you can't argue with that!
Extra credit: Implement this in a more Swift-y way using @krzyzanowskim's pages generator architecture!
The Not-So-Complicated Complications
Haven't had time to watch the Creating Complications with ClockKit WWDC 2015 session? This is a really nice overview for understanding the coding basics for how Complications work. Hey, they're not as complicated as they sound!
Podcasts
Swift 2.0 with Natasha "The Robot" Murashev
I discuss Swift 2.0 (and other things) with @micpringle and @fattjake on the Ray Wenderlich Podcast. Enjoy!
Swift Code
WatchOS2WatchConnectivityDemos - Various projects demoing Watch Connectivity framework
KYDigitalFontView - KYDigitalFontView is a custom view that displays the character in the digital font style
MaterialView - Material Floating Button for iOS - Swift
DPImageCache - Swift extension for UIImageView. Help loading image asynchronously and store local file cache.
UIImageColors - iTunes 11 style color fetcher for Swift UIImage.
Business
Throw Money at It
This article keeps coming up in my mind over and over again as I notice the types of problems businesses have to deal with. The idea is simple. There are two kinds of problems: ones that can be solved by throwing money at them and ones that are more gray area / difficult to find a real solution to. The powerful message here is that problems that can be solved by money are the easy ones.
Swift Thoughts
I've been working on converting a Swift 1.1 project into Swift 1.2 last week (I know it's late!), and one thing that popped out at me was how natural it felt downcasting using as
in Swift 1.1 and lower in certain cases, yet how wrong it now feels with as
being switched to as!
in Swift 1.2.
I've been working on my dissonance with the conclusion that in some cases, it's really ok to use as!
. After some discussions, I agree with @allonsykraken on when to use implicitly unwrapped optionals.