Swift
Learn more and get better in Swift using this list of Swift blog posts, tutorials, tips, and tricks.
Xcode refactoring options explained with examples
A brand new Xcode refactoring engine was introduced in Xcode 9. Although this is quite a few Xcode versions ago it is still a quite unknown functionality for a lot of us. You might have read my blog post on command-click options but do you know how to extract methods ...
UIKeyCommand how-to add keyboard shortcuts & speed up your workflow
The UIKeyCommand class allows you to add keyboard shortcuts to your app. Although they might seem useful for iPad only, there are reasons to add this to your iPhone app as well. They're easy to set up and they work in the simulator! After I wrote Shortcuts essentials in Xcode ...
Combine debugging using operators in Swift
Combine debugging can be hard with long stack traces which don't help at all. Asynchronous callbacks follow up on each other rapidly and easily make it hard to find the root cause of an issue. It's next to the big learning curve one of the most common reasons to not ...
Creating a custom Combine Publisher to extend UIKit
A Custom Combine Publisher can add missing functionalities to UIKit elements you use every day. A lot of boilerplate code can be removed and implementations can be simplified. A simple example is responding to UIControl events. The standard library comes with a few great extensions to, for example, decode JSON ...
Dynamic Member Lookup combined with key paths in Swift
Dynamic member lookup has been introduced in Swift 4.2 with SE-195 and already allowed some pretty nice solutions to for example implement JSON parsing. Just like the @propertyWrapper keyword as discussed in last weeks blog post, it can be used with a @ keyword: @dynamicMemberLookup. As quoted from the proposal, ...
Using NSBatchDeleteRequest to delete batches in Core Data
An NSBatchDeleteRequest can be used to efficiently delete a batch of entries from a Core Data SQLite persistent store. It runs faster than deleting Core Data entities yourself on a managed object context as they operate at the SQL level in the persistent store itself. Its usage, however, is a ...
Weak self and unowned self explained in Swift
Weak self and unowned self in Swift for many of us are hard to understand. Although Automatic Reference Counting (ARC) solved a lot for us already, we still need to manage references when we're not working with value types. When writing Swift code we often run into situation while writing ...
Typealias usage in Swift
A typealias in Swift is literally an alias for an existing type. Simple, isn't it? They can be useful in making your code a bit more readable. By using them in a smart way they can be really useful in your codebase. Declaring a typealias A typealias can be declared ...
@unknown default usage with enums in Swift
@unknown default has been introduced in Swift 5 with SE-0192. It's a new addition to the way we can work with Swift enums and helps us to prepare for future changes. After updating your project to Swift 5 you might end up with a new warning in Xcode 10.2: Switch ...
Swift 5.0: How to migrate your project and frameworks
Swift 5.0 has been released in March 2019 and is the first ABI stable Swift release. Although a lot of resources cover the new things in Swift 5.0, they do not often offer you information on what you need to do to update your project to Swift 5.0. In this ...
Blog about Swift: Tips and ideas to start your own
How to start your own Swift blog? It's a question I get asked more and more. I've given some tips already in my interview with hackingwithswift.com, but it's not as good as writing a dedicated post to help you start up your own blog. May 2nd, 2015 I wrote my ...
Required keyword usage in Swift classes and structs
The required keyword in Swift can be used in front of initializers in Swift. Its usage is simple and it's a small use-case, but the usage of the keyword can easily be understood in the wrong way. Required initializers Some think that the required keyword makes only that initializer available ...