Swift

In this tutorial, you will learn how to check if a UITextField contains a value in Swift. I will cover the following topics: Understanding the isEmpty property. Using the isEmpty property to check if a UITextField is empty. Handling the case when the UITextField is empty. If you are new to UITextField, check out this tutorial: Create…

Read More Check If UITextField Contains Value

In this Swift tutorial, you will learn how to create a UIBarButtonItem with an image programmatically. It will be a short tutorial, but it will cover the following code snippets in Swift: Creating a UIBarButtonItem with an image. Adding the UIBarButtonItem to the navigation bar. Handling the tap event of the UIBarButtonItem. If you are new to UIBarButtonItem, please check…

Read More UIBarButtonItem with Image Example in Swift

In this Swift tutorial, you will learn how to create UIBarButtonItem programmatically without using the storyboard or the interface builder. I will cover topics such as: Create UIBarButtonItem programmatically. How to set the right sidebar button item rightBarButtonItem. How to set the left sidebar button item leftBarButtonItem. How to set target action on UIBarButtonItem to…

Read More Create UIBarButtonItem Programmatically

In this tutorial, you will learn how to perform a time-consuming task in a background thread in Swift. In iOS development, achieving concurrency primarily involves effectively utilizing multi-threading. Running multiple threads can give the appearance of simultaneous execution, which is crucial for keeping the UI responsive while performing heavy computations or network requests. Why Background…

Read More Time Consuming Task in Background Thread in Swift

In this Swift code example, you will learn how to create a UIButton in Swift programmatically without using the storyboard or the interface builder. This is going to be a short tutorial with a very simple code example, but it will contain a lot of useful details like: Create UIButton programmatically in Swift, Position UIButton…

Read More Create UIButton Programmatically in Swift

In this tutorial, I will share with you a few code examples on how to work with dates in Swift.  I will use DateComponents to add more days, months, or years to the current Date object in Swift. Let’s start with the basics. The first thing you need to know is that Swift provides several…

Read More Add Days, Months or Years to a Current Date in Swift

In this tutorial, you will learn how to handle errors in Swift. Errors in Swift are unexpected events that occur during program execution. They can be caused by various factors such as invalid user input, device failure, loss of network connection, physical limitations (like running out of disk memory), or code errors. Throw Statement In…

Read More Error Handling Example in Swift

In this tutorial, you will learn how to compare strings in Swift. You will learn how to check if two strings are the same. Knowing how to do it is essential, especially when dealing with user inputs and form validations in your own apps. Basic Equality Check: The == Operator in Swift The most straightforward way…

Read More Compare Strings in Swift: A Beginner’s Guide

When you’re coding in Swift, managing strings is a crucial part of the process. One frequent task is checking for empty strings, which becomes especially important for tasks like validating user input. In this tutorial, you’ll learn different methods to check for and handle empty strings in Swift. Comparing with an Empty String in Swift…

Read More Check for Empty String in Swift

In this tutorial, I’ll show you how to remove all items from a dictionary in Swift. This is a handy skill to have, especially when you’re dealing with large dictionaries and you want to clear them quickly. Step 1: Create a Dictionary First, let’s start by creating a dictionary. A dictionary in Swift is a…

Read More Remove All Items From a Dictionary in Swift