Swift has been out for over 7 months now, and I still learn new patterns and ways to do things all the time. And when I do know how to do something, I end up questioning if there isn't really a better way and if the better way is really better if the code isn't as readable (looking at you Generics and Custom Operators). Plus now with Swift 1.2, I'll have to re-learn and re-do what I "already know". It is sometimes overwhelming, but most of the time really challenging and fun.
The as! Operator
"Swift 1.2 separates the notions of guaranteed conversion and forced conversion into two distinct operators. Guaranteed conversion is still performed with the as operator, but forced conversion now uses the as! operator. The ! is meant to indicate that the conversion may fail. This way, you know at a glance which conversions may cause the program to crash."
Swift Around the Web
Swift: Counting Strings
So happy about this: "With Swift 1.2,
countElements() has been replaced with
count()". Of course counting strings in Swift is still pretty confusing, especially when you add emojis to the mix. The important part is to realize why you're counting. If you just need to know if the string exists or not, use the built-in
isEmpty() String method.
Looping Through Objects in an Array
This is a good reminder that sometimes the simplest way to accomplish iterating through objects in an array is via a simple for-loop. Although I do love closures.... Make sure to click on the link to Chris Lattner's comment on the topic.
How to fake namespaces in Swift if you really must...
Swift Summit Conference, London March 2015
Meet speakers including Chris Eidhof, Daniel Steinberg and Airspeed Velocity, as well as top iOS engineers from Facebook, Twitter and Venmo as they take you through Getting up to speed on the State of Swift. 2 full days in London this March, conference tickets available now! Go to: SwiftSummit.com
Functional Programming in Swift: Chapter 2- Thinking Functionally
"There is one very important thing to remember about functional programming versus imperative programming:
- Imperative programming is about telling the computer how to do something.
- Functional programming is about telling the computer what to do.
... So let’s take a step back and ask what are we actually trying to do, without thinking about how it will get done."
Try, Option or Either?
This post is in Scala, but provides a very relevant explanation of error handling that heavily applies to Swift, especially the Option and Either explanations and walk-throughs.
Real Story about WatchKit
This is a pretty hilarious real-world explanation of what the first version of WathcKit is actually capable of, how to discuss the limitations of WatchKit with Product Managers, and how to make what seems impossible actually happen within in the limited layout options in WatchKit.
Better Core Data models in Swift
I love how readable using typealias makes code, and using it heavily with CoreData as @jesse_squires points out is no exception. Sure there are still problems, but Swift + CoreData definitely have a lot of potential: "Sometimes it seems like Swift is bringing out the worst in Cocoa and Objective-C. Here's to hoping the toolset will improve — and when Cocoa finally dies, I'll be cheering for a Swift re-implementation of Core Data."
Solving the binding problem with Swift
Taking advantage of Swift's property observers and generics to solve the binding problem. This is definitely one interesting solution to consider when architecting your app.
MotionKit - Get the data from Accelerometer, Gyroscope and Magnetometer in only Two or a few lines of code. CoreMotion now made insanely simple
PathDynamicModal - A modal view using UIDynamicAnimator, like the Path for iOS.
MediumMenu - A menu based on Medium iOS app.
SwiftGraphics - Bringing Swift goodness to Quartz.
KDCircularProgress - A circular progress view with gradients written in Swift
Custom View Controller Presentation Transitions with Swift
"In this tutorial, you’ll create your own custom presentation transitions controller to replace the default animations and liven up tutorial’s starter project."
Creating Custom Animated Buttons
Create a fun bounce button animation.
Swift 1.2 Beta: An overview, and some thoughts
In this session Joseph Lord gives a short overview of the surprise Swift 1.2 Beta update released on February 9th. Some thoughts on the improvements, and perhaps, what remains unaddressed.
"The Watchkit architecture makes for some interesting challenges regarding getting data out of your main app and onto the watch. This covers the architectural and lifecycle basics before diving into the methods we have available to move data around to the watch."
Apple Watch UI Kit
Free! "In this kit, you can find 4 watch views, one with a plain strap, one with a custom strap, a side view and an angled view. There are also a large selection of elements and dotted and dashed boxes with multiple arrow heads as well."
It’s Only Color
Good intro to color for others who are as clueless about this stuff as I am...
Random Cool Stuff
Excellent quote by Jeff Bezos courtesy of a great speech by @OlgaVidisheva
"When you are 80 years old, and in a quiet moment of reflection narrating for only yourself the most personal version of your life story, the telling that will be most compact and meaningful will be the series of choices you have made. In the end, we are our choices. Build yourself a great story." - Jeff Bezos