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. By adding weak by default you probably end up working with optionals in a lot of … 

 

Self-documenting code to improve readability in Swift

Self-documenting code can improve the readability of your codebase. It basically means that you don’t have to write comments to explain what your code is doing. Its advantages can be listed as followed Improved readability of your codebase Code is easier to understand Forces to think of single responsibility With a few basic tips, it’s … 

 

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 in Swift using the typealias … 

 

@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 covers known cases, but ‘UNAuthorizationStatus’ may … 

 

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 very first blog post. At … 

 

Fileprivate vs private in Swift: The differences explained

Fileprivate and private are part of the access control modifiers in Swift. These keywords, together with internal, public, and open, make it possible to restrict access to parts of your code from code in other source files and modules. The private access level is the lowest and most restrictive level whereas open access is the … 

 

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 when creating a class. Instead, … 

 

Alamofire vs URLSession: a comparison for networking in Swift

Alamofire and URLSession both help you to make network requests in Swift. The URLSession API is part of the foundation framework, whereas Alamofire needs to be added as an external dependency. Many developers doubt whether it’s needed to include an extra dependency on something basic like networking in Swift. In the end, it’s perfectly doable to implement a networking layer …