Programming Articles

Page 1957 of 2547

Explain the usage of Classes and the Benefits of Inheritance in Swift

Nitin Aggarwal
Nitin Aggarwal
Updated on 21-Dec-2022 368 Views

Introduction This article will guide you about the usage of Class and what are the benefits of using inheritance in the Swift language. In this article, we will cover the following things − What is a class and what is its usage in Swift? What is inheritance and what are its benefits? What is a Class? In the Swift language, a class is a representation of properties and methods. We use classes to encapsulate properties and methods into a single entity that has the same characteristics. We use classes to store information in variables and constants. A class ...

Read More

Designing patterns used during iOS app development

Nitin Aggarwal
Nitin Aggarwal
Updated on 21-Dec-2022 739 Views

In this tutorial, you will get to know about some common design patterns that you should follow while making iOS apps. What are Swift Design Patterns? In Swift, design patterns make the development process easy for developers. A productive and effective work environment can be created by following the design patterns. An iOS design pattern is a set of repeatable methods for creating apps. What are the most common design patterns used in iOS development? Builder Facade MVC Singleton Viper MVVM Adaptor Observer Factory Method Let's talk about some of them to understand how they work − Algorithm ...

Read More

Difference between Incremental Model and WaterFall Model

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 21-Dec-2022 7K+ Views

The Waterfall model and the Incremental Model are widely used in software development. The objective of having these models is to ensure that the software is developed in a systematic, organized and efficient manner. Read this article to find out more about the Waterfall model and the Incremental model and how they are different from each other. What is the Incremental Model? The incremental Model is a software development model in which the entire model is divided into various sub−development phases where the corresponding testing phase for each development phase is practiced. The execution of the phases, i.e., ...

Read More

Swift Program to Find the Transpose

Ankita Saini
Ankita Saini
Updated on 20-Dec-2022 638 Views

In this article, we will learn how to write a swift program to find the transpose of a matrix. Transpose of a matrix is calculated by interchange the rows of a matrix into columns or columns of a matrix into rows. For example, we have the following matrix: $$\mathrm{X\:=\:\begin{bmatrix} 13, & 59, & 32, & 67 ewline 23, & 56, &89, & 3 ewline 98, & 3, & 32, & 43 ewline 6, & 90, & 43, &23 \end{bmatrix}}$$ So the transpose of matrix X is − $$\mathrm{X^{T}\:=\:\begin{bmatrix} 13, & 23, & 98, & 6 ewline 59, ...

Read More

Difference Between Cohesion and Coupling

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 20-Dec-2022 25K+ Views

The most basic difference between cohesion and coupling is that coupling is the representation of relationships between modules which uses the concept of inter−module, while cohesion is the intramodule representation of the relationship between modules. Read this article to find out more about Cohesion and Coupling and how these two important concepts are different from each other. What is Cohesion? In computer programming, cohesion is an indication that shows the relationship within modules. Cohesion provides the information about the functional strength of the modules. The greater the cohesion, the better will be the program design. Cohesion is basically the dependency ...

Read More

Swift Program to Sort the Elements of an Array in Descending Order

Ankita Saini
Ankita Saini
Updated on 20-Dec-2022 881 Views

In this article, we will learn how to write a swift program to sort the elements of an array in descending order. To sort the elements of an array Swift provides an in-built function named sort(by:). This function takes one argument and then sorts the array according to the condition passed in the by parameter. So to sort the array in descending order we pass > in the by the parameter of the sort(by:) function. Syntax func sort(by:) Here sort(by:) is an instance method. Which will sort the given sequence according to the value of by: parameter. Here ...

Read More

Swift Program to Sort the Elements of an Array in Ascending Order

Ankita Saini
Ankita Saini
Updated on 20-Dec-2022 3K+ Views

In this article, we will learn how to write a swift program to sort the elements of an array in ascending order. Here we are going to use the following 2 methods: sort() function without parameter sort(by:) function with parameter To sort the elements of an array Swift provides an in-built function named sort(). This function can work with or without parameters. By default this function sort the array in ascending order. Otherwise, you can pass < in the by a parameter of the sort(by:) function to sort the array in ascending order. Method 1: sort() Function Without ...

Read More

Swift Program to Remove All Occurrences of an Element in an Array

Ankita Saini
Ankita Saini
Updated on 20-Dec-2022 945 Views

In this article, we will learn how to write a swift program to remove all occurrences of an element in an array. So here we use the following methods − Using an inbuilt function Without using an inbuilt function Method 1: Using the removeAll() Function To remove all the occurrences of an element in an array we use a pre-defined function named removeAll(where:). This function removes all the elements from the given sequence that satisfy the given condition. For Example − Array = [2, 3, 5, 67, 2, 87, 2, 68] Element = 2 Output array = [3, 5, 67, ...

Read More

Swift Program to Print an Array

Ankita Saini
Ankita Saini
Updated on 20-Dec-2022 5K+ Views

This article will teach us how to write a swift program to print an array. To print an array, we are using the following methods − Using array name Using for loop Using a while loop Using forEach() method Method 1: Print the array using the array name We can print an array by directly using the name of the array in the print function. Syntax Following is the syntax − print(arrayName) Here we simply pass the name of the array in the print function to display the array. Example The following Swift program shows how to print ...

Read More

Swift Program to Find Common Array Elements

Ankita Saini
Ankita Saini
Updated on 20-Dec-2022 2K+ Views

This article will teach us how to write a swift program to find common array elements. So here we use the following methods − Using the filter method Using sets But before moving to the methods, we first understand common elements with the help of an example. Suppose we have two arrays − Arr1 = [2, 4, 6, 89, 78] Arr2 = [56, 88, 32, 4, 99, 89] So the common elements between two arrays are [4, 89]. Because they are available in Arr1 and Arr2. Method 1: Using filter(_:) Method To find common elements between two arrays ...

Read More
Showing 19561–19570 of 25,466 articles
Advertisements