Exploring the Swift Standard Library: Hidden Gems You May Not Know About

Swift is a powerful and versatile programming language that’s ideal for building iOS apps. While you’re probably familiar with many of its features, there are a number of hidden gems in the Swift Standard Library that you may not know about. In this article, we’ll explore some of these lesser-known features and show you how … Read more

Quickly generate random numbers in swift

Swift has a random function, build in the language core. It can be used to generate random values for float, Int, Double and Bool. The below code examples will make the usage clear

How to convert String to an Int in swift

In swift a String can be converted into a Int in a very easy and safe way. Below example will show how we can easily convert a String to an Int value nil coalescing can also be used if we wish to return a default value in case of a invalid string Hope this helps!!!

Split a comma separated string into swift array

If you have got a string which is separated using any delimiter like ‘,’ or space or ‘|’ or any other fixed delimiter, you can easily split it in swift by using the following function

Sorting swift array

We can easily sort a swift array using two provided function array.sort array.sorted We will see both array.sort() and array.sorted() in action and will understand how they differ from each other in a subtle way, while sorting a swift array in place and returning a sorted copy of the swift array. Example code for the … Read more

Convert degrees to radians and radians to degrees

In real life, we are used to degrees and in programming, we deal mostly with radians. If you are dealing with drawing specifically arc and circles you will come across situations where you have to toggle between degrees and radians and at other times between radians to degrees. Relationship between Degrees and Radian The above … Read more