
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 516 Articles for Swift

238 Views
In this article, we will learn how to write a swift program to display lower triangular matrix. Lower triangular matrix is a matrix in which all the elements above primary diagonal are zero. As shown in the below image: $$\mathrm{\begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0ewline 3 & 5 & 0 & 0 & 0 & 0ewline 1 & 4 & 6 & 0 & 0 & 0ewline 1 & 2 & 2 & 2 & 0 & 0ewline 4 & 5 & 6 & 1 & 2 & 0ewline 1 & 1 & 1 ... Read More

786 Views
In this article, we will learn how to write a swift program to compute the sum of diagonals of a matrix. Every matrix has two diagonals which are known as primary and secondary diagonals. For example, we have the following 5x5 square matrix − 2 3 4 5 6 4 6 7 8 9 1 1 1 3 4 4 0 4 0 4 0 0 1 1 1 So the primary diagonal is formed by using elements 2, 6, 1, 0, 1 and the secondary diagonal is formed by using elements 6, 8, 1, 0, 0. Hence the ... Read More

175 Views
In this article, we will learn how to write a swift program to check whether two matrices are equal or not. Here, we create two matrices, and using the not equal to the operator (!=), we check whether all the elements of both matrices are equal or not. Algorithm Step 1 − Create a function. Step 2 − Use nested for loop to iterate through each row and column. Step 3 − Check if the element of matrix1 is not equal to matrix2. If the condition is true, then return 0, otherwise, return 1. Step 4 − Create two ... Read More

716 Views
In this article, we will learn how to write a swift program to calculate standard deviation. Standard deviation is a measure, which will represent how much variation from the mean exists, or we can say that it is used to calculate the extent to which the values are differ from the average. $$\mathrm{\sigma\:=\:\sqrt{{\frac{1}{N}}\sum_{i=1}^N\:(X_i-\mu)^2}}$$ The mathematical formula of standard deviation is- σ = standard deviation N = total number of elements Xi = ith element \mu = Mean of the given elements Therefore, in this article, we calculate the standard deviation of the given array by using the ... Read More

3K+ Views
In this article, we will learn how to write a swift program to calculate averages using an array. Average is defined as the ratio of the sum of the elements present in the given sequence to the total number of elements available in the given sequence. The general formula of average is − Average = (p1+p2+p3+..+pn)/n Here we use the following methods to calculate the average using array − Using pre−define functions Without using predefine functions Method 1: Using Pre-Define Functions To find the average of the given array, we use reduce() method to find the sum ... Read More

3K+ Views
Since Array and NSArray are both core constructs in iOS development, we sometimes forget just how different they are. Here are some major differences between the two constructs that you should know about. Array is a struct, therefore it is a value type in Swift. NSArray is an immutable Objective C class, therefore it is a reference type in Swift. Array is a Swift construct, and generic struct, which means that it can be an array of any specific type (Int, String, etc.). [T] is syntactic sugar for Array. NSArray is an Objective-C construct that can hold any Objective-C ... Read More

1K+ Views
Throughout this article, you will learn what an attribute in Swift is and how to use it with code examples. Swift Attributes Swift makes it possible to provide some additional info about the declaration or type. We have two types of attributes that can be used in Swift language. Declaration Attributes Type Attributes Syntax You can apply an attribute by using the symbol @ followed by the attribute name, as shown below − @attribute name @attribute name(attribute arguments) Explanation We can provide arguments in declaration attributes to define the declaration. These arguments can be provided in parentheses ... Read More

5K+ Views
In this article, you will learn about what Delegate is and how it works. What is Delegation? As the name implies, delegation gives control to other objects. To make it happen, the delegate object has to be assigned to control other objects. In iOS apps, the UIApplicaitonDelegate is an example. UIApplicationDelegate allows you to modify iOS behavior, such as receiving push notifications, opening URLs, and launching apps. A delegation pattern ensures the functionality that needs to be delegated is provided. Delegate patterns enable objects to communicate back to their owners decoupled from their code. It is much easier to ... Read More

1K+ Views
In this article, you will learn about the different execution states of an iOS application. Based on the current state, you can decide what task you want to perform. There are different states that an app might have. The iPhone operating system (iOS) provides us with different five states of an application like the following − Not running Inactive Active Background Suspended An iOS application runs in several states, known as states of the application life cycle. App life cycles are crucial for iOS developers, as they help them understand how their apps behave. The following states are ... Read More

2K+ Views
In this article, we will discuss Swift's comments, why, and how to use them correctly in Swift. Always keep one thing in mind while writing code i.e. The code must be written for people to read and understand as much as possible. Similarly to the Swift language, comments are very useful for making your code more easily understandable to you and other developers. All the comments in the code are completely ignored by the Swift compiler. There are two types of comments in Swift − Single Line Comments Multiline Comments Single Line Comments Syntax Swift allows us to ... Read More