Found 33676 Articles for Programming

How do I change the 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

How do I add 1 day to an NSDate?

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

342 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

Getting a "This application is modifying the autolayout engine from a background thread" error?

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

181 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 the class name of an object as a 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

Generate a UUID on iOS from Swift

Nitin Aggarwal
Updated on 06-Sep-2023 18:14:04

1K+ Views

This article will explain to you what is the UUID in iOS and how to generate it in the Swift language. You will see some practical situations in which UUID is useful in the iOS application. What is UUID? A universally unique identifier (UUID) is a string of characters that is guaranteed to be unique across all devices and at all times. UUIDs are often used to uniquely identify resources, such as database records or files. In iOS, UUIDs can be used for a variety of purposes. Some common use cases for UUIDs in iOS include − Identifying app-specific ... Read More

Golang program to implement a weighted interval scheduling algorithm

Akhil Sharma
Updated on 05-Sep-2023 19:03:01

287 Views

The Weighted Interval Scheduling Problem revolves around a set of intervals, each having an associated weight. In this article, we will implement the Weighted Interval Scheduling algorithm in go, using two methods: Recursive and Dynamic Programming. This classic optimization problem involves selecting non-overlapping intervals with maximum total weight. Explanation Recursive Method The Recursive Method takes a straightforward yet elegant approach. It examines each interval one by one and considers two scenarios − whether to include the current interval or skip it. This method utilises recursion to explore all possible combinations of intervals, calculating the maximum weight. While ... Read More

Golang program to implement a treap

Akhil Sharma
Updated on 05-Sep-2023 18:46:19

209 Views

In this article, we will explore the implementation of a Treap data structure in Golang using two different methods. A Treap is a combination of a binary search tree and a binary heap, making it an efficient data structure for maintaining a set of ordered elements while also ensuring balanced priority. The first method will utilise a recursive approach for building and maintaining the Treap, while the second method will implement an iterative approach. The examples below showcase the creation and traversal of a randomised binary search tree, Explanation A Treap is a cool combination of two other structures, a ... Read More

Golang program to implement a bitset

Akhil Sharma
Updated on 05-Sep-2023 18:08:26

442 Views

A BitSet is a data structure that represents a fixed-size set of binary values, where each value can be either 0 or 1. It is commonly used for efficiently storing and manipulating large sets of boolean values. In this article, we will implement a bitset in go, using two different methods, the first one involves the use of slice of booleans as well as the second one involves using bit manipulation with unsigned integers. Implementation here means that we are going to perform various operations like setting, clearing and testing of individual bits within a bitset data structure. Explanation ... Read More

Golang program to implement a trie with compressed nodes

Akhil Sharma
Updated on 05-Sep-2023 17:57:26

226 Views

Tries are tree-like data structures used for efficient storage and retrieval of strings, making them invaluable for tasks like autocomplete, dictionary implementation, and pattern matching. The compressed node technique optimises space usage by merging common prefixes among nodes, resulting in a more memory-efficient Trie. In this article, we will explore the implementation of a Trie with Compressed Nodes in Golang using two methods to implement the Trie with Compressed Nodes, the first method utilises maps, and the second method uses arrays. Explanation A compressed trie is a trie data structure that saves the space by combining consecutive nodes with ... Read More

Golang program to implement a double ended priority queue

Akhil Sharma
Updated on 05-Sep-2023 17:54:25

259 Views

A Double Ended Priority Queue, in short DEPQ is a data structure that extends the functionality of a standard priority queue. In this article, we will implement a double ended priority queue in Golang using two methods: the first method uses two separate heaps for maximum and minimum priorities, while the second method augments a single heap with additional information for efficient queries. In the code examples we are going to perform the operations like insertion retrieval, deletion and updation. Explanation Double ended priority queue is a data structure that allows insertion and deletion operations and it allows efficient ... Read More

Advertisements