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 determine which Xcode was used to develop from code
In my role as an iOS developer and manager, I come across situations where I get full source code from our freelancers and associates. Whenever there is the latest version of Xcode released we get keen on knowing which Xcode was last used to develop the app? Why this question is important? The need to … Read more
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
Understanding swift defer statement
Defer statement in swift is executed just before the control exits the scope in which defer is defined. Swift’s official document states
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
Latest way to Set A Root View Controller Programmatically in Swift
While trying to set a custom rootViewController in swift with a UIWindow, in the traditional way results in a black screen. The reason is now we need to use UIWindowScene to create a UIWindow instance.
Deleting 9gag comments easily
It is a very tough job to delete 9gag comments from a very active thread as your comment will be hidden somewhere amongst thousands of comments. But I will share with you an easy way to do it. Using this method you will be able to go to your comments directly one by one and delete them no need to search for needles in a haystack.