
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

786 Views
In Swift, you can easily call a method along with parameters on the main thread through GCD. You can use the DispatchQueue.main.async method to execute a method on the main thread. Let's learn how to achieve this in Swift. Also, you can call a method with parameters after a delay using the DispatchQueue.main.asyncAfter method. Grand Central Dispatch (GCD) In iOS, macOS, and other Apple operating systems, Grand Central Dispatch (GCD) is a low-level C API that offers effective, system-wide control of concurrent processes. It is constructed on top of the dispatch queues and thread management primitives at a lower level. ... Read More

5K+ Views
In Swift, you can remove subviews of a view by using a loop to iterate through each subview. Swift provides a method called removeFromSuperview() to remove a view from its superview. In this article, you will learn how to use this method with some examples. removeFromSuperview() This method belongs to the UIView class in Swift. This can be used to remove a view object from its superview. To call this method, you need to call it from a view object which needs to be removed from the superview. When you run removeFromSuperview() on a view, it sends a message to ... Read More

5K+ Views
In Swift, there is a framework called AVFoundation that provides flexibility to play audio files. This framework provides you with a class called AVAudioPlayer to manage audio play and pause. In this article, you will learn how to play a sound using the AVAudioPlayer class in Swift. AVFoundation This framework is a very powerful multimedia framework in Swift. This provides you with most of the features to work with media files like audio, video, and other types of media files. This framework uses some common classes to manage media files. AVPlayer − This is a class that supports high-quality ... Read More

8K+ Views
In Swift, you can use the UIDevice class to get a unique device ID. In this article, you will learn how to get a unique device ID using the identifierForVendor property in Swift. What is the UIDevice Class? Swift's UIDevice class gives access to device information like as name, model, system version, and unique identifier. Here's a rundown of some of the most significant attributes and methods of the UIDevice class − current − The current device object is returned by this class attribute. name − This property returns the device's name. model − The model of the device, ... Read More

3K+ Views
In Swift, there is the Date class to work with all kinds of date formats. You can manipulate and format date objects using the Date class. There are other supported classes like DateComponents, DateFormatter, etc that help you format date objects from one type to another type. Let's learn about dates with some examples. In Swift, you can create a Date object using the Date() initializer, which returns the current date and time − let currentDate = Date() Creating a Date Object From a String Representation You can create a Date object from a string representation of a date ... Read More

2K+ Views
In Swift, you can use the "+" operator and join function to join the strings. You can concatenate multiple strings using this operator. In this article, we will see some examples of how to concatenate the strings. Here are several examples of using the operator and in-built functions. Algorithm Step 1 − Create the strings Step 2 − Combine both strings using the given function Step 3 − Print the input and output string on the console Example 1 In this example, we will see an example of adding two strings with a space. import Foundation let ... Read More

881 Views
In Swift, you can use the DateFormatter class to convert a string date to a date object. This class provides date conversion properties and methods. In this article, we will see some examples of date conversions. DateFormatter Class Swift's standard library has a class that is used to convert dates. It may be used to change a string into a date object and the other way around. To parse date objects in various formats, this class offers attributes and methods. You must build an object of the DateFormatter class in order to transform a string to a date object and ... Read More

332 Views
In Swift, a set is used to create an unordered collection of unique elements. To split a set into two halves we use a approach in which we first determine the midpoint of the given set using integer division method and then loop through the set and insert element into either the first half or second half set according to the index related to the midpoint. For example − Original Set - [2, 4, 5, 6, 7, 1] Set1 - [2, 4, 5] Set2 - [6, 7, 1] Algorithm Step 1 − Create a function which takes ... Read More

638 Views
Selection sort algorithm in swift is a sorting algorithm, in which it select smallest or largest element from the given unsorted array and place that element at the beginning of the unsorted array. This process continue till the last unsorted element. So now we sort an array in descending order using selection sort. For example − Array: [6, 10, 3, 7] 1st iteration − For the first position iterate through whole array starting from in 0 to 3. After traversing through whole array we find 10 is the greatest number so swap 6 with 10. Resultant Array: ... Read More

483 Views
Bubble sort algorithm in swift, is the easiest search algorithm. This algorithm sorts the elements by repeatedly swapping adjacent elements if they are not present at the right place. So now we sort an array in descending order using bubble sort. For example − Array - [4, 7, 1, 8] 1st iteration − compare two elements, if the first element is smaller than second element then swap their position. If not, then move to next pair. [4, 7, 1, 8] 41, remain same [7, 4, 1, 8] 14, remain same [7, 4, 8, 1] 41, remain same ... Read More