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 277 to 288 of 716 posts
10:18
Up until now we submitted blocks of work to a dispatch queue by invoking the async(execute:) method. In this episode, we explore how Grand Central Dispatch handles the execution of a block of work. Work can be executed synchronously or asynchronously. What does that mean? What is the difference? And what are the risks?
in Swift
7:48
In the previous episodes, we used dependency injection to easily replace objects with mock objects when the unit tests are executed. It's a solution that works fine and it can be applied in a wide range of scenarios.
in Swift
13:16
We're currently only unit testing the happy path. In this episode, we expand the test suite and I show you how to simulate failures. It isn't easy to accurately test failures in the real world and that emphasizes the importance of a robust test suite. Let me show you what I have in mind.
in Swift
4:00
The interface of the RootViewModel class shows that we only need to unit test the initializer and the refresh() method. I explained earlier why I don't unit test the initializer and, in the previous episodes, we unit tested the refresh() method. Does that mean that the test suite now completely covers the RootViewModel class? The answer is no. This is a common mistake developers make. In this episode, we collect code coverage data to expose the gaps in the test suite.
in Swift
8:28
We wrote the first unit test for the RootViewModel class in the previous episode. It's true that unit testing asynchronous code is more complex than unit testing synchronous code, but I hope that the previous episode has shown that it isn't that hard.
in Swift
6:40
Developers that are new to unit testing often wonder what they should unit test. Unit testing is a type of black-box testing, which means that you don't care how the entity under test does what it does. From the moment you start writing unit tests, you need to stop being a developer and take on the mindset of a tester. What do I mean by that?
in Swift
10:49
Earlier in this series, we wrote unit tests for the DayViewModel, the WeekViewModel, and the WeekDayViewModel structs. Writing those unit tests was fairly straightforward. Unit testing the RootViewModel class is a bit more challenging for a number of reasons. The RootViewModel class asynchronously fetches the location of the device and weather data for a location. To unit test asynchronous operations, we need to take a different approach.
in Swift
9:04
The application we worked with in the previous episodes creates and manages a serial dispatch queue and a concurrent dispatch queue. Creating a dispatch queue manually is fine, but it isn't always necessary. Grand Central Dispatch manages a handful of dispatch queues your application can use. The main dispatch queue is one of these dispatch queues. In this episode, we find out which dispatch queues Grand Central Dispatch provides and when you should consider using them.
in Swift
11:12
You should now have a fundamental understanding of dispatch queues. A dispatch queue is responsible for managing the execution of blocks of work. Grand Central Dispatch determines which thread is used for the execution of a block of work. Developers unfamiliar with Grand Central Dispatch wrongly assume that a dispatch queue is tied to a particular thread. Remember that Grand Central Dispatch doesn't make a guarantee as to which thread is used for the execution of a block of work submitted to a dispatch queue.
in Swift
10:22
Dispatch queues are an integral part of Grand Central Dispatch. In this episode, we cover the fundamentals of dispatch queues. Let's start with an example.
in Swift
3:54
I'm not a fan of random string literals in a project and I always try to find solutions to avoid them. In today's episode, I show you an elegant solution to rid a project of string literals.
7:40
You've probably heard about Grand Central Dispatch and chances are that you've used it in some of your projects. This series takes a close look at Grand Central Dispatch. Before exploring the API of Grand Central Dispatch, we find out what it is and what problem it solves.
in Concurrency