Swift How to save a file from a URL with Swift In this tutorial I will show you how you can download a file from a given URL and then save it locally using Swift. Setting up the local file URL The first thing that I want to do is to setup the local file url. In this tutorial I will
UserDefaults How to store a date in UserDefaults with Swift UserDefaults can be a useful tool to store small amounts of information. In this tutorial I will show you how you can store a Date in UserDefaults using Swift. Storing a date in UserDefaults Below is the code that we will use to save the date: let defaults = UserDefaults.standard
Swift How to save an image to file with Swift There are numerous reasons to save an image to a file using Swift. In this tutorial I will show how you can do that with just a few lines of code. Before we get started I want to add a method that we will use in both saving of a
Swift How to save data to file with Swift There are many reasons that we might need to save data to a file as an app developer. We might need to save an image, or text or something else. In this tutorial I will show you how we can save a string to a file, but this can be
Swift How to save/write Json to file with Swift In this tutorial I will show you two methods that you can use to write JSON data/string to a file using Swift. Save JSON string to file Saving a JSON string will be the same as saving any other kind of string. Since Swift will see it as a
Python Python - list all files starting with given string/prefix In this tutorial I will show you how to list all files in a directory where those files start with a given string/prefix. Find files in the current directory To loop through the provided directory, and not subdirectories we can use the following code: for file in os.listdir(
CocoaPods How to Remove CocoaPods from your Project In this tutorial I will show you how to you can remove Cocoapods from your project. Removing Cocodpods is extremely easy to do all we need to do is to install two Ruby gems: sudo gem install cocoapods-deintegrate cocoapods-clean Now that we have the required gems, we can deintegrate and
Xcode How to rename an Xcode project Renaming a project can be a common task. You could start with a name for your project and then during the development process you decide that you want to rename the project. Unfortunately Xcode does not come with built in functionality to do this, so we need to do it
Swift How to sort a dictionary by value with Swift Every now and then you might need to sort a dictionary by value, luckily, dictionary comes with a sorted method built in. I am going to use the following dictionary as an example: let dictionary = [ "a": "A", "b": "B", "c"
JSONEncoder How to Convert an object to JSON with Swift There could be a few reasons why you would want to convert a swift object to JSON. In this tutorial we will take a look at how we can convert a swift object to a JSON string and how to convert the JSON string to a swift object. First, let&
Swift Hide home indicator with Swift The iPhone X removed the home button and replaced it with what Apple calls the home indicator. Apple has allowed us to hide the home indicator which can be useful if your app needs to hide the indicator. Some examples could be for a video player app, photo app, map/
Swift Hide navigation bar on Scroll or Tap with Swift Have you noticed on some apps where the navigation bar will hide when you start scrolling or if you tap? In this tutorial we will look at how we can do this. The best part about this functionality is how easy it is to implement. Links * Hide on scroll * Hide
UITableView Create a UITableView with Swift In quite a few of my tutorials I need to add a section that will explain setting up a UITableView even if the tutorial does not focus on UITableView specifically. I do this so that readers can see exactly what I have done from the start, who knows, maybe their
Getting started with LazyVGrid/LazyHGrid in SwiftUI SwiftUI has just been updated and it has some great new features/views. One or two of them being LazyVGrid and LazyHGrid. So, in todays tutorial, we will be going through some of the basics of how to use these two new views. To start off with, what is LazyVGrid
UITableView Change UITableView separator color In this quick tutorial I will show you how to change a UITableView's separator color. There are two ways to do this, both are very easy, but there is one that I personally prefer to use. Links * Change separator color with Interface Builder * Change separator color with Swift(
SwiftUI Pass SwiftUI view as argument to another view I assume since you are reading this article that you want to be able to pass a view or multiple views as an argument to another view using SwiftUI. In this tutorial we will learn how we can use ViewBuilder to achieve this. Step 1: Create a custom view This
SwiftUI SwiftUI TextField Character Limit I have written about how to add a character limit to UITextField so I thought that I might as well write a tutorial on how to add a character limit to a SwiftUI TextField. There are few things that change when doing it for SwiftUI. These changes are mainly due
SwiftUI Resize an image with SwiftUI Images are not always the exact size that we need which is what leads me to writing this tutorial. Depending on the situation you might have an image that is too big or too small. > TLDR: To resize an image we need to use the resizable view modifier on
SwiftUI SwiftUI list remove padding(Left and Right) SwiftUI can be great, for specific tasks it makes getting things done a breeze, but for others, it works in unexpected ways. Removing padding from a list is one of those things that really does not make sense to me. This is how I thought I could remove padding from
Swift How to convert array to string with Swift In some situations one might want to convert an array of strings to a string. There are a few ways to do this, all are quick and easy but for most use cases the simplest solution will be the best solution. Array.joined Array.joined is the simplest solution out
Swift Get keyboard height in SwiftUI I have written about getting the height of the keyboard before, you can find that article here [https://programmingwithswift.com/keyboard-height-with-swift/]. In this article I am going to be changing it up bit, we will be looking at how to use @Published, ObservableObject and @ObservedObject which can make it a
UITableViewCell UITableViewCell swipe actions with Swift iOS 11 brought a new way to add custom swipe swipe actions to UITableViewCell's. In this tutorial we will learn how to add those swipe actions to table view cells, as well as go through some of the things to look out for when adding swipe actions. When
Swift Remove UITableViewCell highlight/selection color with Swift This is one of those annoying default behaviours that iOS has. Below is a one liner that will help you remove the cell highlighting. To remove the table view cell highlight/selection color all you need to do is this: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
Swift Add UITextField to UIAlertController with Swift In this tutorial I will show you how to add text fields to a UIAlertController using Swift. This is one of those tasks that is surprisingly simple as it is built into UIAlertController. Just before we get to the code, my project is a new project and all the code
Swift Reload UITableView row/cell at IndexPath Reloading an entire table view is not always the best way to update the data in the table view. It might be better to reload specific rows/cells in the table view. In today's tutorial we will be learning how to do this, luckily, Apple has made this