Working with Assets Catalogs in Xcode

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:33 am | 4-min read

Assets catalogs are super useful to organize your app’s assets in Xcode. Drop graphics, images, icons, colors and vectors into an asset catalog and use them directly in your app’s code. In this tutorial, we’re going to discuss: How to add colors and images to an asset catalog How you use asset catalogs in practical iOS development Different sizes and scales for images Using colors with Dark and Light Mode How to use colors and images from an asset catalog in your code Tabl [...]

Read More

Fun with print() in Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:33 am | 6-min read

You use print() in Swift to print a string of text to the Console, or standard output. It’s super useful for debugging and finding out what’s going on in your code. In this tutorial, we’ll discuss how you can customize print() to code more productively. Here’s what we’ll get into: How do you use print() in Swift? Working with #file, #function and #line literals print()‘s separator and terminator Printing a description of custom Swift objects Table of Contents Writ [...]

Read More

Initializers & init() Explained in Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:33 am | 6-min read

In Swift, an initializer is a special init() function that we use to create objects of a particular class, struct or type. They’re used to “construct” an instance of the given type. In this tutorial, we’re going to discuss how initializers work, why they’re needed, and how you can write your own. We’ll focus on the different kinds of initializers, such as convenience initializers, what the consequences are of subclassing, errors you may face in day-to-day iOS development, and much [...]

Read More

@ObservedObject and Friends in SwiftUI

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:33 am | 6-min read

In this tutorial, we’re going to discuss an approach for 2-way data flow between a web-based JSON resource and changing that data in your app. Getting data, displaying it, and sending changes back. The centerpiece is the @ObservedObject property wrapper, and we’ll also discuss how to use ObservableObject, @Published, @Binding, Combine, MVVM, and much more. Here’s what we’ll get into: How to set up 2-way data flow in a real-world Books app Working with @ObservedObject, @Binding and [...]

Read More

How To Generate a Random Unique Identifier with UUID in Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:32 am | 4-min read

Random unique identifiers (UUIDs) are super useful in Swift programming. Imagine you’re storing objects in a database, and every object needs a unique ID. The generated ID needs to be unique, universally, across all devices, all users, all objects in the database. How do you generate such an ID?. Table of Contents Generating Random Identifiers with UUID What’s RFC 4122? UUIDs: Universally Unique Identifiers UUIDs in Practical iOS Development Further Reading Generating Rand [...]

Read More