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 697 to 708 of 716 posts
Downloading images using Swift and the URLSession API isn't too difficult. The question is "Where do you store the images you download?" It is important that you know where you can and cannot store the images your application downloads. A safe place to store images is in the Documents directory of the application container. In this post, I show you how to store an image in the Documents directory using Swift. I promise you that it isn't difficult.
in Fundamentals
Almost every application needs to persist data in the application's sandbox. One option is to store data in the Documents directory of the application container. The question is How do you get the location of the Documents directory in Swift? This is easier than you might think.
in Fundamentals
Most developers don't worry where Core Data stores its data and many probably don't know where the persistent store is located in the application's sandbox. To debug Core Data issues, however, it can be useful to access the persistent store and inspect its data. In this post, I show you where you might find the data Core Data stores.
in Core Data
Core Data has been around for more than a decade and it has grown into a robust persistence solution. I have used Core Data in dozens of applications and enjoy working with the framework. Some developers swear by Core Data while others passionately dislike it.
in Core Data
Even though the UserDefaults class offers an easy-to-use API, I always create an extension for the UserDefaults class. Why is that? What are the benefits of an extension for UserDefaults? That is the focus of this post.
in Fundamentals
Developers that are new to Swift or user defaults are often confused why some of the data stored in the user's defaults database isn't persisted. To understand why and when this might happen, you first need to know more about the defaults system and how it stores data.
in Fundamentals
Many developers that are new to Swift and Cocoa development wonder what they should use, Core Data or the defaults system. I understand the motivation for this question, but it's the wrong question to ask. Core Data and the defaults system are very different persistence solutions. Both solutions can be used to persist data, but that is the only thing they have in common.
in Fundamentals
The title of this post is a bit misleading, because you should not store images in the user's defaults database. That is not what it was designed for. With this post, I hope I can convince other developers to use a different solution for storing images in the application's sandbox.
in Fundamentals
The UserDefaults class has a fairly extensive API that should meet most of your needs. From time to time, however, you need to perform a task that is less trivial. How do you clear the user's defaults database? The UserDefaults class doesn't offer this functionality. What options do you have to reset the user's defaults database in Swift?
in Fundamentals
Interacting with the defaults system is easy thanks to the UserDefaults class. You can store a range of data types in the user's defaults database, including strings, numbers and Date objects. The UserDefaults class is available on iOS, tvOS, macOS, iPadOS, watchOS and Mac Catalyst.
in Fundamentals
The UserDefaults class makes it trivial to store small pieces of data and persist them across application sessions. The problem is that only strings, numbers, Date objects, and Data objects can be stored in the user's defaults database. How do you store an enum in the user's defaults database in Swift? I answer that question in this post.
in Fundamentals
The UserDefaults class makes it straightforward to store data in the user's defaults database, but remember that only strings, numbers, Date objects, and Data objects are supported by the defaults system. Is it possible to store a custom object in the user's defaults database? It is, but it requires a bit of additional work.
in Fundamentals