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.
Learn Swift and iOS development through comprehensive video guides
Showing 73 to 84 of 420 posts
3:37
If you have been reading or watching Cocoacasts for some time, then you know that the Model-View-ViewModel pattern is one of my preferred patterns for architecting applications. I have been using MVVM for several years in various projects and it continues to prove its value in every project I work on.
7:18
I love working with enums in Swift. While that may sound odd, I feel enums are undervalued and developers miss out on some of their nicer applications, especially when combined with associated values.
in Fundamentals
6:40
Types are a fundamental aspect of the Swift language. Swift's type system was pretty easy to understand in the early days. As the language matured, the type system gained in complexity to increase its flexibility. That flexibility came at a cost, though. Today's type system is pretty advanced and some aspects make your head spin.
in Fundamentals
5:57
In the early days of the Swift language, it took just a few hours to learn the fundamentals of the language. I'm sorry to say that that is no longer true. Swift has become richer and, as a result, more complex. The language has become much more capable, but those capabilities come at a price, increased complexity.
in Concurrency
11:04
You learned in the previous episode that it is fine to ignore some of the gaps Xcode finds in your test suite. Even though the goal isn't to fill every gap, we need to write a few more unit tests for the APIClient class.
in Networking
11:05
Unit tests are very useful for testing edge cases. We explored that in the previous episode. Because bugs sometimes hide in edge cases, unit tests can help you track down hard to find bugs. This is only true if the unit tests you write are sound and cover your code.
in Networking
8:25
One of the key benefits of a robust test suite is its ability to quickly and easily test scenarios that are uncommon or hard to reproduce. In this and the next episode, we write unit tests for several scenarios that are difficult to test manually. Manual testing has value, but it is time-consuming and it can be tedious to test edge cases.
in Networking
11:55
Step by step we are increasing the code coverage of the APIClient class. In the previous episode, you learned how to use the APIs the APIClient class exposes to unit test its private methods. Remember that the goal isn't to unit test the private methods of the APIClient class. The goal is to increase the code coverage of the APIClient class. We have a few more unit tests to write.
in Networking
8:33
Code coverage is a very helpful tool to detect gaps in a test suite. In the previous episode, we enabled code coverage to learn how to write better unit tests for the APIClient class. The coverage report shows that the episodes() method is fully covered. It also reveals that the private request(:) method lacks coverage. Even though the request(:) method is private to the APIClient class, we can write unit tests to indirectly test it and increase coverage of the APIClient class. That is the focus of this episode.
in Networking
7:10
Are the unit tests we wrote for the /api/v1/episodes endpoint sufficient? How many unit tests should we write? These are some of the questions we answer in this episode. Developers often struggle with unit testing because they aren't sure when enough is enough. As a developer, you want a simple, straightforward answer. The good news is that code coverage can provide that answer.
in Networking
9:29
We can drastically improve the unit tests we wrote in the previous episodes. Even though the unit tests pass without issues, string literals and code duplication are subtle hints that we should take another look at the unit tests we wrote. At the end of this episode, we have a framework in place that we can use for the remaining unit tests of the APIClient class.
in Networking
8:42
To create a robust test suite, we need to be in control of the environment the test suite runs in. That includes being in control of the requests the application sends to the Cocoacasts API. We don't want the application to hit the Cocoacasts API when the test suite is run. In this episode, I show you how to stub the Cocoacasts API using the OHHTTPStubs library.
in Networking