swift

swift

Three different Swift programs to check if a dictionary contains a key or not

Three different ways to check if a swift dictionary contains a key or not. We can check if the value is nil for a key, we can use if let or index(forKey) method of dictionary.

Read
swift

How to check if an array of integers contains two numbers appeared twice in swift

Swift program to check if an array of integers contains two numbers appeared twice or not. We will use one dictionary to find out the duplicate numbers.

Read
swift

Swift program to check if a number is odd or even

Swift program to check if a number is odd or even and print out the result. We will learn how to find it using the modulo operator, using isMultiple method, and for a double using the remainder method with examples.

Read
swift

How to find the remainder in swift using modulo

In this tutorial, we will learn how to find the remainder in swift. Swift provides one operator % to find out the remainder. Let's check how it works :.

Read
swift

Swift program to check if a number is a multiple of another

We can check if a number is multiple of another number or not easily by division. If we divide the first number by the second number and if the remainder is 0, the second number is a multiple of the first number. But, swift also provides one method called isMultiple that we can use to find out if a number is multiple of another number or not. In this tutorial, we will learn how to use this method.

Read
swift

Swift tutorial : Recursive enumeration in Swift

We know that a function is called recursive if the function itself is called from it. Similar to recursive function, in swift we have recursive enumeration. If any case in the enumeration contains one or more associated value as another instance of the Enumeration itself. For example, let's take a look at the below example :.

Read
swift

Associated values in swift enumeration and how to use them

In this tutorial, we will learn what is associated values in swift and how to use them. To learn more about associated values, suppose we are writing an iOS application in swift that will greet the user differently for the first time use and second time use.For example,suppose user 'Albert' is using the app for the first time. It will show one message Hello Albert ! Welcome to our app.. Similarly, after 10 time when he will open,it will print Hey Albert ! Thank you for using our app for more than 10 times. Please give us a rating on Appstore.. How we are going to use it ? Yes,we have different ways to solve this problem but we will learn how to solve it using enum in swift :.

Read
swift

Enumeration in Swift : explanation with examples

Enumeration is actually used to define a common types of group of data.For example, following is a enumeration with seven different values or cases :.

Read
swift

Using raw values in swift enumeration

In swift, we can assign raw values while defining an enumeration.Means these are default values for enumeration cases. Let's take a look at the below example :.

Read
swift

Swift program to get the index for a key in Dictionary

In this tutorial, we will learn how to get the index of a key in swift Dictionary. Many time we need the index for a key in a dictionary. We can use this process at that time. Let me show you with an example :.

Read