swift

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
ios

(iOS) Adding Swipe gesture to a view in Swift 4

In this tutorial, we will learn how to add swipe gesture in iOS applications using swift 4. The swipe gesture can be added to any view. For example, you have one custom notification over your application and you want to remove it if the user swipe from left to right. In that case, we need to add one gesture recognizer on that view. We will add one custom ’view’ and show you how to add all top, bottom, left and right swipe gesture recognizer for that view. Let’s have a look :.

Read
swift

Different return types in swift functions

We can write functions without any return values . That means, if you call the function, it will return no value and the program will continue running from the next line. Example :.

Read
swift

Swift 4 Tutorial : Split and Join a String

Sometimes we need to change one part of a string . Suppose you have three different types of url for your image - "http://mysite.com/image/myimage.jpg" for default size, "http://mysite.com/image/myimageh360w360.jpg" for "360*360" sized image and "http://mysite.com/image/myimageh100w100.jpg" for "100*100" sized image. You have access only to the first url and you will have to change it like second and third url. How to do that ?

Read
swift

How to run a piece of code on main thread in Swift 4

While running a code on background thread, sometimes we need to push a code on to the main thread. In this tutorial, we will learn how to achieve this while developing ios apps in Swift 4 . Let's take a look :.

Read
swift

Swift 4 tutorial : continue statement

Suppose your program has a loop ( for or while ) and you want to skip some specific conditions, i.e. you don't want to run the code inside the loop for these conditions. 'continue' statement is used for that. It informs the loop to stop for that iteration and continue from the next iteration. In this tutorial , we will check different use cases of 'continue'. 'The syntax used for 'continue' is :.

Read
swift

Swift 4 while and repeat-while loop tutorial with example

In this tutorial, we will learn about while and repeat-while loops in swift. For both cases, I have added one example :.

Read
swift

Swift 4 for-in loop Tutorial with Example

For-in loop is used to iterate over sequence like array, dictionary, string etc. In this example, I will show you use of for-in loop with different examples.Drop a comment if you have any queries.

Read
swift

Swift switch tutorial with Example

Switch statement takes a value and compare it with different cases. If any case matches, it runs a block of code. It is like using multiple 'if' conditions and checking each of them one by one. A switch statement can be defined as below :.

Read