#swift

Found 79 articles tagged with #swift

An example using builder pattern in Swift

The builder pattern allows you to create objects with varying configurations without the need to have multiple constructors with different parameter combinations.

Different ways to parse JSON data in Swift

Choose Codable for well-defined JSON structures, JSONSerialization for simple parsing tasks or legacy codebases, and SwiftyJSON for dynamic or exploratory parsing needs.

Apr 07, 2024#swift#json

Difference between KVO and KVC in Swift

While KVO and KVC are related and both are part of Cocoa's observation mechanism, they serve different purposes and operate at different levels of abstraction.

Apr 04, 2024#swift#objc#ios

How to achieve dependency injection manually in Swift

In DI, dependencies are provided to it from an external source, typically through constructor injection, property injection, or method injection instead of a class creating itself.

Mar 24, 2024#swift#patterns

How to handle multiple async tasks in Swift

Swift offers a few ways to handle multiple asynchronous tasks, depending on whether you need them to run concurrently or wait for their results.

Mar 23, 2024#swift

Difference between private and fileprivate in Swift

In Swift, private provides the strictest level of access control. You should only use fileprivate when you have a specific reason to allow access from other parts of the same file.

Mar 09, 2024#swift#comparison

What's New in Swift 5.10

Swift 5.10 accomplishes full data isolation in the concurrency language model. This important milestone has taken years of active development over many releases.

Difference between compactMap and flatMap in Swift

Method compactMap removes nil results from optional value sequences during transformation, and flatMap flattens nested sequences into a single level sequence.

Mar 04, 2024#swift#comparison

How to use variadic parameters in Swift

Variadic parameters are useful when you want to create a function that can take any number of arguments of a specific type without specifying them individually.

Mar 03, 2024#swift#functions

When to use computed properties or methods in Swift

Both computed properties and methods can provide dynamic behavior, allowing you to calculate values or perform actions based on the current state of an instance.

Feb 26, 2024#swift