Learn Swift programming

Welcome to this online Swift programming learning platform. Here you can learn Swift programming in an easy way.

Remove all the elements from a Swift array

In this tutorial, you are going to learn how to remove all the elements from a Swift array with examples. In Swift, there is a built-in method removeAll(). We can use this method to remove all the items from our array. Before we go forward with this [...]

Swap two elements of an array in Swift

In this Swift programming tutorial, you will learn how to swap two elements of an array with the help of examples. To swap two array items, you can use the swapAt() method. Below is the code: Output: Initial Array: [3, 5, 7, 8, 11] Array after swappi [...]

Remove the last character of a string in Swift

If you want to remove the last character from a Swift string then you can do it easily using the removeLast() or the dropLast() method. Both of the methods are able to perform the task. But there is a difference. The removeLast() method is mutable. S [...]

Sort characters of a String in Swift

In this tutorial, you are going to learn how to sort characters of a String in Swift with examples. In Swift, we are going to use the Swift sorted() method to sort a string by its characters in alphabetical order. It is possible to sort the string in [...]

Swift Array dropFirst() and dropLast()

In this tutorial, you are going to learn about dropFirst() and dropLast() methods in Swift. One method drop the first element and the other method drops the last element of an array. Now let’s learn about these methods in detail with examples&# [...]

Sort an array of strings alphabetically in Swift

Previously I published a tutorial on sorting an array in Swift where you can find examples of sorting arrays of integers. Now in this tutorial, you are going to learn how to sort an array of strings alphabetically. To sort a string type array in alph [...]

Sorting an Array in Swift (Ascending and Descending order)

In this tutorial, you are going to learn how to sort an array in Swift with the help of examples. In the examples, I have covered the sorting of array elements in both ascending and descending order. In Swift, there are two built-in methods sort() an [...]

Get the last N elements from an array in Swift

In this Swift programming tutorial, you will learn how to get the last N elements from an array with the help of an easy example. In Swift, there is a method suffix() that can help us to perform the task. We have to provide an integer as the argument [...]

Swift repeat…while Loop

I have already discussed the while loop in my previous tutorial. Now in this tutorial, you will learn about the Swift repeat…while loop. The Swift repeat...while loop is the same as the while loop with an important difference that makes it sepa [...]

How to use Image Literal in Xcode as it is no longer available

In this tutorial, I will show you an alternative way to do the same thing as Image Literal in Swift Xcode. When I was trying to use the image pick-up option through image literal then I noticed no image literal option is coming up in Xcode. Then, I t [...]

« Previous Page | Next Page »