If you know C or Objective-C then you might be familiar with Enums and Structs. However, if you don’t know either of those languages then you are probably wondering what is their purpose and why you should use them. In Swift, both an Enum and Struct have an extended feature set from...
From Swift 6.1 on we can mark protocols, structs, classes, and enums as beingnonisolated, allowing them to opt out of actor isolation they inherited from elsewhere. This means you'll need to useawaitand similar to access any actor-isolated data you would otherwise have been able to use fr...
A Sendable type is one that can be safely passed around in a concurrent environment, which can include value types such as structs, final classes with constant properties, actors that automatically protect their own mutable state, and more. Before Swift 6 the compiler was very strict: if ...
Although Swift 6 is looming on the horizon, the 5.x releases still have a lot to give – simpler ways to use if and switch, macros, noncopyable types, custom actor executors, and more are all coming in Swift 5.9, making yet another mammoth release. In this article I’ll walk you ...
By learning about the key path, you open up yourself to an opportunity to improve your existing API or even create a new one that you don't aware you can do it.
Now in Swift 2, you can extend protocols and add default implementations for properties and methods. You can already do this with classes and structs — adding new methods to String or Array, for example — but adding these to protocols now gives you a much wider reach. extension CustomStrin...
Swift 4 brings support for Unicode 9 which means that problems with unicode characters counting are now gone: "👩💻".count // 1, in Swift 3: 2 "👍🏽".count // 1, in Swift 3: 2 "👧🏽".count // 1, in Swift 3: 2 - person + skin tone ...
You'll learn how to create your own data types, and create object-oriented applications using classes and structs.Lesson 4, Collections, shows you how to work with Swift's collections, such as arrays, sets, and dictionaries.Lesson 5, Strings, covers Swift strings in detail. We will create ...
We recently wrote aboutSwift structs. In this tutorial, we’ll look at classes. Classes and structures have a lot in common, although there are some important differences. Let’s take a look at what a class is and what you use them for. ...
Metatypes are pretty useful in Swift, and you have certainly used it in multiple occasions. Unfortunately they look pretty weird in code, which can cause some confusion when trying to understand what they really are.