Swift Around the Web
Should I use a Swift struct or a class?
Here is the wonderful tldr; section from this detailed article on when to use structs vs classes:
structs are for "bags of data". Your Ints, your CGRect. Your Person record.
If you find yourself talking to "something else" inside your struct code, where "something else" is the file system, the network, the GPS, you have made a wrong turn somewhere.
If you find yourself with structs that contain structs that contain structs that contain structs, you have probably made a wrong turn somewhere. You'll discover that way the hell down there somewhere you forgot a mutating, and now you have to mark mutating for all the things.
Most types don't need to be threadsafe. Most instances do. Use struct for the 10% of your types that make 90% of the instances. Use class for the 90% of your types that make up 10% of your instances.
If overloading == to compare two things elementwise sounds like a great idea, use a struct. If you hesitate, use a class.
Protocol Extensions
Another reminder to rewire your brain to think bigger with protocol extensions in Swift 2! So if you're extending an Array, consider extending all MutableCollectionTypes. Same applies to dictionaries and all other types that conform to protocols!
Coding
New stuff from WWDC 2015
A simple, yet very comprehensive, list of all the new stuff that came out at WWDC 2015. Really nice for scanning to see which additional things you need to learn this year!
Adapting Stack Views With Size Classes
Rotating an iPhone from portrait to landscape should switch the stack view from vertical to horizontal as the size class changes from regular to compact height, but that doesn't work in the current beta. Hope it's fixed for the GM, but if not, a very simple workaround is provided here.
Apple News
Xcode 7 beta 3
Xcode 7 beta 3 is finally out! And of course the coolest improvement to Swift has to do with enums (see above screenshot from the Release Notes). It's attention to tiny details like these by the Swift team that make Swift such an incredible language to be a part of. So much đź’–!
Design
Meaningful Design for Apple Watch
"Apple Watch doesn’t (or at least shouldn’t) invite you in for further exploration. When it’s meaningful, it’s active. It senses what you’re doing, shows you a targeted bit of meaningful information, and gets out of the way. It’s about highly contextual cues to inform and enrich what you’re doing in real life — right here, right now. And that, I believe, is a fundamentally healthier place for mobile technology."
How to Create an Icon Design Workflow in Sketch App 3
A really good and easy way to finally learn Sketch - thanks @chsweb for sharing.
Other Cool Stuff
Did You Know?
"In German there is a word for when cables under the desk tangle and create a mess: Kabelsalat (Cable Salad)."
In Case You Missed It
iOS: You’re Doing Settings Wrong
One of the apparently less known features for iOS 8 and above is the ability to deep link the user into Settings, where they can enable their Location, Notifications, Contacts, Camera, Calendar, etc for your app as needed. Oh, and it's only 3 lines of code, so there is no excuse not to do it.
Swift: Equatable with Optionals
@andrewcbancroft recently wrote a great article about how Every Swift Value Type Should Be Equatable – go ahead and read it, I’ll wait… One thing that stood out as missing from this article was comparing different sets of optional values. In the past, I have implemented the equality use-cases for values to make sure optionals were covered. Turns out, that wasn't necessary...
Tutorials
OAuth 2.0 with Swift Tutorial
Whenever I've had to implement OAuth 2.0 with an external API in my previous apps, it's been a real pain point. Glad to finally a see a good tutorial on it - and it's in Swift!
Functional Voodoo
Imperative Programming in Swift
"A program is a sequence of those transformations. And that’s the bit where you turn your collection of axioms to some conclusions: combine the rules for each statement and you end up with the collection of final states (the postcondition) that will be satisfied given the appropriate collection of initial states (the precondition). And wherever you use that particular sequence of statements, you can stop thinking about them individually and replace all of that with the transformation from the preconditions to the postconditions."
WATCH
WatchOS 2 Tutorial: Animations Using Groups
Love the new simple, yet powerful ability to animate on the Apple Watch. Thanks @kristinathai for the fun tutorial!
The World’s First Swim App On The Apple Watch
Sadly this app will not be approved... since the Apple Watch is not officially waterproof (maybe the next generation will be!). But I love the detailed explanation of the making of the app - including the detailed use-case, design, architecture, and challenges.
Swift Code
Proposer - Make permission requests easier.
Mirror - Swift objects Reflection
Presentation - Presentation helps you to make tutorials, release notes and animated pages.
Kamagari - Simple UIAlertController builder class in Swift.
Static - Simple static table views for iOS in Swift.
Business
Instant App Websites
Super useful if you're just starting out - create a beautiful website from your App Store page in minutes. Oh, and it's FREE at the moment.
Swift Thoughts
I know what you're wondering, so here it is. Yes, of course, I watched the Minions movie on opening day!!! So fair warning - my upcoming talks have a strong chance of being yellow :)