Shuffle an Array in Swift

Nitin Aggarwal
Updated on 07-Sep-2023 09:14:06

436 Views

In this article, you will learn how to shuffle an array in the Swift language. In Swift, you can use the shuffle() and shuffled() methods to shuffle the array elements. shuffle() The shuffle() method shuffles the elements of the collection in place, so the original array is modified. shuffled() If you want to create a shuffled copy of the array instead of modifying the original array, you can use the shuffled() method from the Sequence protocol. Here is an example of how to use shuffle() to shuffle the array elements Algorithm Step 1 - Create an input array Step ... Read More

Make Attributed String Using Swift

Nitin Aggarwal
Updated on 07-Sep-2023 09:10:50

684 Views

This article will explain how you can make an attributed string in the Swift language. What are the steps to apply different attributes to a string in Swift? In Swift, we use the NSAttributedString class to make an attributed string. In Swift, NSAttributedString is a class used to create and manage attributed strings. An attributed string is a string that has additional attributes, such as text color, font, and style, applied to parts of the string. This article will show different use cases for an attributed string. Basic Setup import UIKit class TestController: UIViewController { private ... Read More

Change Font Size of a UILabel in Swift

Nitin Aggarwal
Updated on 07-Sep-2023 08:58:53

3K+ Views

You can change the font size of a UILabel in Swift by setting the font property of the UILabel to a UIFont object with the desired point size. Here is the code for the basic setup import UIKit class TestController: UIViewController { private let messageLabel = UILabel() override func viewDidLoad() { super.viewDidLoad() initialSetup() } ... Read More

Add 1 Day to an NSDate in Swift

Nitin Aggarwal
Updated on 07-Sep-2023 08:55:29

356 Views

In this article, you will learn how to add the number of days to a date in the Swift language. Many times, you might need to modify the date by changing some number of days, weeks, months, etc. Swift provides an in-built concept for adding a component to date. Let's see some examples. Let's take a brief look at a few of the common concepts that will be used in these examples. Calendar Class The Calendar class in Swift is a class that represents a calendar, which is a system for organizing dates. It is used to perform calendar-related calculations, ... Read More

Fixing the 'This Application is Modifying the AutoLayout Engine from a Background Thread' Error

Nitin Aggarwal
Updated on 07-Sep-2023 08:50:34

189 Views

In iOS development, this error frequently occurs while working on user interfaces. Also, you can reduce the chances of coming across this error if you write code carefully. Let's understand what this error is all about. It will help you to understand the reason behind this error if you read the error statement. The error "This application is modifying the autolayout engine from a background thread" is caused when an application attempts to make changes to the user interface from a background thread, which is not allowed in iOS development. Autolayout is a system for defining the layout of user ... Read More

Get Class Name of an Object as String in Swift

Nitin Aggarwal
Updated on 07-Sep-2023 08:49:13

2K+ Views

This article will explain to you how to get the name of the class of an object in the Swift language. Swift provides us with a function called type(of:) to get the type of a value or the class name of an object. You can use the type(of:) function to find the dynamic type of a value, particularly when the dynamic type is different from the static type. The static type of a value is the known, compile-time type of the value. The dynamic type of a value is the value’s actual type at run-time, which can be a subtype ... Read More

Cast from Varchar to Int in MySQL

George John
Updated on 07-Sep-2023 01:05:54

42K+ Views

To cast VARCHAR to INT, we can use the cast() function from MySQL. Here is the syntax of cast() function. cast(anyValue as dataType) For our example, we will create a table with the help of CREATE command. mysql> create table VarchartointDemo -> ( -> Value varchar(100) -> ); Query OK, 0 rows affected (0.51 sec) After creating a table, let us insert some records into the table with the help of INSERT command. The query is as follows − mysql> insert into VarchartointDemo values('123'); Query OK, 1 row affected (0.26 sec) ... Read More

Difference Between Combinational and Sequential Circuit

Kiran Kumar Panigrahi
Updated on 07-Sep-2023 01:02:47

37K+ Views

In digital electronics, both combinational and sequential circuits are the most widely used circuits. These are two broad categories of circuits defined in the digital electronics where one type of circuit is independent of time and other is dependent on time. Read this article to find out more about combinational circuits and sequential circuits and how these two circuits are different from each other. Let's start with a basic overview of combinational and sequential circuits so that it becomes easier to understand how they are different from each other. What is a Combinational Circuit? A combinational circuit is one whose ... Read More

Reset or Clear a Form Using JavaScript

Prabhdeep Singh
Updated on 06-Sep-2023 22:09:50

45K+ Views

This tutorial teaches us how to reset or clear a form using JavaScript. This option is very helpful for users in the situation where they have filled the wrong form and before submitting they get to know about it and now they want to delete all the data. If the form is too large then manually deleting everything may be hard so it's better to use the reset() method of JavaScript. The reset() method is defined in JavaScript and by just clicking on it the form which will be linked to its onclick() method will reset every input section of ... Read More

Add Space Between Elements

Shabaz Alam
Updated on 06-Sep-2023 22:06:40

66K+ Views

In an HTML web page, the space between elements refers to the area around and between different elements, such as text, images, and other HTML elements. There are several ways to add space between elements in web design. One common method is to use CSS (Cascading Style Sheets) to create margins and padding around elements. Adding space between HTML elements using CSS Web design often requires adding space between elements to create a visually pleasing layout and improve readability. Web design has several ways to add space between elements. One common method is to use CSS (Cascading Style ... Read More

Advertisements