Learn Swift and iOS Development
Master iOS development through in-depth tutorials and comprehensive courses on Swift, SwiftUI, UIKit, Core Data, and more.
Master iOS development through in-depth tutorials and comprehensive courses on Swift, SwiftUI, UIKit, Core Data, and more.
Discover the newest tutorials on Swift and iOS development
Discover the newest tutorials on Swift and iOS development
Showing 625 to 636 of 716 posts
Generating random numbers in Swift is easy and requires only a single line of code. There are a few approaches, though. In this episode of Swift Fundamentals, we look at two options to generate a random number using Swift.
Most developers default to a for loop when they must loop through a collection or perform an operation several times. I find that the value of the while loop is often overlooked. It has some advantages over Swift's for loop in some scenarios. In this episode of Swift Fundamentals, you learn how to use a while loop in Swift and, more important, when it is appropriate to use a while loop over a for loop. Let's get started.
Many developers struggle with the concepts authentication and authorization. They are often used interchangeably. What is the difference between these concepts? While the difference is subtle, it is vitally important. Let's take a look at authentication first.
in Security
What does it mean for Swift to be ABI stable? ABI stands for application binary interface. ABI stability was introduced in Swift 5 and it means that the binary interface of the language is guaranteed to remain stable across different versions of the compiler and platforms.
in Fundamentals
A publisher is nothing more than a sequence of elements over time. Your application typically performs an action when a publisher emits an element. In some scenarios, the action you take requires the elements the publisher emitted up until that point. That is where the scan and tryScan operators come in useful. This may sound confusing so let's take a look at an example.
in Combine
Earlier in this series, I explained how you can use Combine's compactMap operator to filter out nil elements emitted by a publisher. While this is a common use case, there are scenarios in which you don't want to filter out nil elements. Instead you want to replace the nil elements with a default or fallback value. In this episode of Combine Essentials, you learn about the replaceNil operator to do just that. Note that I don't recommend developers to use the replaceNil operator due to its unintuitive behavior. I explain this in more detail in this episode.
in Combine
Looping over a collection is a common task in most programming languages. In this post, you learn about Swift's for loop and you learn that a for loop isn't always the best solution to the problem. Swift has several other constructs that are at times a better fit. Let's start with the for loop.
I write this post in part for my future self because I run into this issue at least once a year. The story goes something like this. You are using Xcode 14 for your daily development and Apple releases iOS 17. You eagerly upgrade to iOS 17 to try out the latest and greatest Apple has to offer. The next time you try to deploy a build to that device, Xcode shows you a dialog that says Could not locate device support files.
in Xcode
Xcode is an advanced IDE (Integrated Development Environment) and it isn't always obvious how to perform seemingly trivial tasks, such as adding a scheme. In this post, I show you in a few simple steps how to add a scheme in Xcode.
in Xcode
The difference between arguments and parameters isn't difficult to understand. Most developers use the term argument and parameter interchangeably because they assume they are the same or they are not sure what the difference is. Let's take a moment to understand what sets arguments apart from parameters in Swift.
in Swift
Time zones are convenient, but they are usually a pain for developers. Numerous bugs have made it into production because of time zones. The good news is that Apple's Foundation framework makes working with time zones pretty simple. In this episode, we take a look at Foundation's TimeZone struct and how to use it in a project. Fire up Xcode and create a playground if you want to follow along with me.
Mapping a dictionary to an array isn't difficult. You have a few options, the map(_:) method being my personal favorite for most situations. Converting an array to a dictionary is less trivial. Swift's Standard Library doesn't seem to offer an API to make this straightforward. In this episode, I show you two solutions.