Since the introduction of
SwiftUI, I have seen many developers write all their code inside views. Unfortunately, the simplicity of the framework seems to encourage a return of many poor practices.
But you do not build robust, maintainable apps by gluing together random pieces of code.
Sure, you can search on Google for specific tasks, copy and paste some code into your project and make it work, somehow.
That works if your app is small and simple. But as soon as you go beyond basic tutorials, you inevitably get serious problems.
That’s why the MVC and MVVM patterns exist. In this article, we will see how they apply to SwiftUI.
Networking is a requirement for most modern iOS apps.
Networked apps usually interface with a remote web service that provides the data. And often, this web service is a REST API that returns data in JSON format.
Writing the networking layer of an iOS app, though, is not a simple task. To make asynchronous network calls, you need to use many features of Swift and UIKit, like the URLSession class and the Codable. Moreover, many parts of the app’s architecture need to interact, making the task more complicated than it seems.
After the introduction of protocol extensions in Swift, Apple started pushing protocol-oriented programming.
Even if it was a new paradigm, it quickly got widespread adoption in Swift programming and iOS development.
This is not a surprise. Protocol-oriented programming is a highly flexible paradigm with many benefits. One of my favorite applications is to create well-structured
Protocol-oriented programming solves many of the problems of object-oriented programming. Moreover, it works great with Swift’s value types, i.e., structures and enumerations.
For loops are a fundamental construct of programming, and even more so of making iOS apps. If you want to
become an iOS developer, they are a necessary tool you need to have in your toolbox.
But more important than simply understanding how they work, is to know how to use them for the different tasks you will meet in iOS development.
So, the aim of this article is not only to show you how Swift for loops work, but how to use them to solve the most common programming problems.
Table views are a fundamental component of almost any iOS app. But most developers don’t use them when they should or get their architecture wrong.
Table views are more versatile than you might think.
For example, many developers make their life harder using a scroll view when a
would be a better choice. UITableView
architecture is crucial for table views. The code of the table view data source often ends inside view controllers when it should go into a separate class.
Even though Apple introduced SwiftUI at WWDC 2019, you won’t be able to use it in your apps until a large portion of users gets on iOS 13.
Until then, you need to know the right approach to using table views with data sources and delegates.
Since the introduction of Swift, the iOS community has been buzzing with the words
That’s because many features of Swift were inspired by the ones you find in functional programming languages.
These features make some tasks easier. One example is easily configurable callbacks for
While Swift is not a functional language, we can draw many lessons from functional programming to write better Swift code in our iOS apps.
Unwind segues in iOS can be quite confusing.
Unlike their forward counterpart, they are based on a more complicated mechanism and different rules. That usually complicates their setup.
Moreover, many wonder why you should use an unwind segue when you can dismiss a view controller with a single line of code.
I will answer all these questions in this article.