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 ...
In Swift, declarations are used to define variables, constants, classes, structures, functions, and other entities. Swift uses type inference, which allows the compiler to automatically determine the data type based on the initial value assigned. ...
Computed properties are part of a family of property types in Swift. Stored properties are the most common which save and return a stored value whereas computed ones are a bit different. A computed property, it’s all in the name, computes its property upon request. It can be a valuable ...
You’re probably familiar with access-level modifiers like public, private, and internal for classes, methods, and properties. Starting with Swift 6, you can also apply these to package imports: internalimportFrameworkDependencyprivateimportFrameworkDependencyOnlyForThisFilepackageimportFrameworkDependencyOnly...
Conclusion You delegate work to someone/something else who can do it. Delegation helps you separate concerns, decouple classes, and make your code more reusable. The best place to start with delegation is between your view and your view controllerNitin...
This new feature introduces statically callable values to Swift. But what does that mean? Well, it means that you can call classes or other structures as if they were functions.To implement this feature in your code, you add a method named callAsFunction(_:) to the type. That’s it!
Note: This has changed in later versions of Swift – all closures are considered to be non-escaping by default.Classes can now have static methods and properties Swift 1.2 gives us an alias for class final properties: static. While class variables may be overridden in subclasses, static variabl...
In Swift 1, protocols were like interfaces to specify a set of properties and methods that a class, struct, or enum would then conform to. 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 ...
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 ...
Objective-C and Swift are very different if you take a close look at both languages. The change introduced by SE-0116 means that it should be possible to bridge any Swift type to an Objective-C object. This isn't a problem for classes and bridged value types, such as Int, String, ...