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
Server Side Programming Articles - Page 340 of 2650
5K+ Views
Swift has various methods to append elements to a dictionary. We will use the below methods to append elements in a dictionary in the Swift language − Append elements using the updateValue() method Append elements using the subscript syntax. Append elements using the merging() methods. Using the updateValue() method The updateValue( :forKey:) method in swift is used for updating the value for an existing key or adding a new key-value combination to an existing dictionary. The method will return nil instead of the key's prior value if the key wasn't previously present in the dictionary, Here is an ... Read More
1K+ Views
You can specify the range operator using two syntaxes (..< or ...). These two syntaxes are used for different purposes. As part of the first syntax, the starting and ending values of the range are included. In contrast, the second syntax includes a starting value as well as an optional ending value. For example, you want to specify a range from the number 1 to 4. You can define it like this 1..
2K+ Views
You can use the Timer class in Swift to create a timer that can execute a method repeatedly at a specified time interval. You can implement the timer to solve different problems. You can schedule repeatable and non-repeatable timers in Swift. Timers in Swift can be used to perform a variety of tasks, such as − The process of carrying out a specific action or chunk of code at specified intervals of time, such as updating a display or changing a label's content, or performing any other UI action. Sending a reminder or establishing a background activity that will ... Read More
1K+ Views
In Swift, you can make a weak protocol reference by using the weak keyword when declaring the variable or property that holds the reference to the protocol. The weak reference helps you to avoid the retain cycle creation. What is a weak protocol reference? A weak protocol reference in Swift is a technique for defining a protocol that a class can use without starting a strong reference cycle. When two objects maintain strong references to one another, preventing either object from being deallocated, this is known as a strong reference cycle. One of the objects is able to deallocate the ... Read More
349 Views
In Swift, you can define a base class using the class keyword. The base class can be used to implement common properties using a single class. You can define the properties and methods in a class like the one below − class MyBaseClass { // properties and methods go here } A subclass is also defined by the class keyword. In a similar way, you can define the properties and methods in the class. To make it a subclass, you have to mention the parent class followed by the parent class name after the colon like ... Read More
3K+ Views
In this article, you will learn various ways to generate random alphanumeric strings in the Swift language. Here we are going to use the following 3 methods to generate a random alphanumeric string in swift − Using the RandomNumberGenerator protocol Using the Random() function Using higher-order functions Using the RandomNumberGenerator protocol Swift 5 comes with a random() function that is added to the Foundation framework. We will use the RandomNumberGenerator protocol as the random() function is a part of this protocol.Example The following example demonstrates on how to use the random() function to generate a random alphanumeric ... Read More
377 Views
In Swift, there are two different concepts i.e. protocols and superclasses are used to build the application by writing reusable and flexible code. They both are different concepts but somehow they have some common features. You can define the protocol with methods and properties to achieve any particular feature. In the same way, you can create a class with methods and properties to hold some information. Swift provides flexibility in that class, structure, and enums can conform to a protocol. A superclass is also a class type. It can be inherited from other classes in a similar way. In this ... Read More
2K+ Views
In this article, you will learn about how to create a button prograticamtilly in the Swift language. There are different ways to create a button object programmatically in iOS. Let's explore some of them with an example. We will see the following ways to create a button − Step 1 − In this step, we will create a button object and customize it later when required. Step 2 − In this step, we will create a button object using a lazy keyword. Step 3 − In this step, we will create a button object and set the frame later. ... Read More
7K+ Views
In Swift, you can use the layer property of a UIButton to set the corner radius of its border. You can use the layer (CALayer) property to apply the border width and color to the button. Also, the same property provides access to the cornerRadius property to make the button rounded. We will use the following steps to make a button rounded with a border Step 1 − In this step, create a button object with basic customization. Step 2 − In this step, add a border and corner radius to the button. Step 3 − In this step, make ... Read More
8K+ Views
To change the text of a UIButton in Swift, you can use the setTitle() method of the button. This method takes an argument to set the button title for a particular state. Generally, we used the normal button state. We will change the text of the button programmatically by following the below steps − Step 1 − In this step, we will create two buttons (login and T&C) and add basic customization. Step 2 − In this step, we will change the text of the login button. Step 3 − In this step, we will change the text of the ... Read More