Create a Swift Date Object

Nitin Aggarwal
Updated on 24-Apr-2023 10:57:35

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

Concatenate Strings in Swift

Nitin Aggarwal
Updated on 24-Apr-2023 10:55:40

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

Full Form of BBC

Praveen Varghese Thomas
Updated on 24-Apr-2023 10:54:50

307 Views

What is the Full Form of BBC? BBC stands for British Broadcasting Corporation. This is the biggest TV network. It is the world's biggest broadcasting organisation, with origins stretching over several continents. Over 3, 5004 stars are employed full- or part-time, permanently, financially, and in a timely way by this company. The yearly television license fee serves as this business's funding source. This company offers a wide range of services to the public, including newspapers, television, radio, online music, and many others. It is a publically funded system. In addition to English, the dominant language, they also broadcast the ... Read More

Convert String Date to NSDate

Nitin Aggarwal
Updated on 24-Apr-2023 10:54:27

884 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

Split a Set into Two Halves in Swift

Ankita Saini
Updated on 24-Apr-2023 10:52:21

333 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

Sort an Array in Descending Order Using Selection Sort in Swift

Ankita Saini
Updated on 24-Apr-2023 10:48:16

643 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

Sort an Array in Descending Order Using Bubble Sort in Swift

Ankita Saini
Updated on 24-Apr-2023 10:46:23

485 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

Sort Array in Ascending Order Using Quick Sort in Swift

Ankita Saini
Updated on 24-Apr-2023 10:44:58

725 Views

Quick sort algorithm in swift is a sorting algorithm which works on divide and conquer approach. In this sort, we first divide the array into subarrays by selecting a pivot element. Here the division takes place in such a way, in which the smallest elements placed at the left side of the pivot element and the largest element placed at the right side of the pivot element. Now the right and left subarrays are also divide using the same approach. This process continue till all the subarrays contain one element. At this point the array element are sorted now we ... Read More

Full Form of BA

Praveen Varghese Thomas
Updated on 24-Apr-2023 10:44:25

334 Views

Introduction A Bachelor of Arts (BA) degree is an undergraduate academic degree program that typically takes four years to complete. It is a broad-based degree program that covers a wide range of subjects such as humanities, social sciences, or liberal arts. A BA degree provides a well-rounded education that develops critical thinking, communication, and analytical skills, which employers across different industries highly value. BA graduates have a higher earning potential and better job prospects compared to individuals without a degree. BA programs often offer opportunities for internships, research projects, study abroad programs, and extracurricular activities that enhance students' ... Read More

Sort an Array in Ascending Order Using Selection Sort in Swift

Ankita Saini
Updated on 24-Apr-2023 10:41:00

1K+ 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 ascending 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 3 is the smallest number so for the 1st position swap 6 with ... Read More

Advertisements