Check if String Contains Special Characters in Swift

Anvi Jain
Updated on 29-Jun-2020 14:04:33

3K+ Views

To check if a string contains a special character in swift we can use conditionals like if else or switch but that would need a lot of conditions to be executed, making programming as well as execution time consuming. So in this example we’ll see how to do the same task with regular expressions and another method that swift provides to check if some character exists in a character set.Method 1 − Using regular expressionLet’s create an extension of String and add the following code into thatextension String {    var containsSpecialCharacter: Bool {       let regex = ... Read More

Detect Shake Gesture Using Swift

Rishi Rathor
Updated on 29-Jun-2020 14:03:26

1K+ Views

To detect a shake gesture in iOS UIKit provides three different methods, let’s see them one by one.Method 1 − When the shake gesture begins.override func motionBegan(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { // code you want to implement }Method 2 − When the shake gesture ends.override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { // Code you want to implement. }Method 3 − when the shake gesture is cancelled.override func motionCancelled(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { // code you want to implement. }Now let’s add some code in our motionBegan method, override func motionBegan(_ motion: UIEvent.EventSubtype, with event: ... Read More

Navigate from One View Controller to Another in iOS

Vrundesha Joshi
Updated on 29-Jun-2020 14:02:43

6K+ Views

To navigate from one view Controller to another view Controller in iOS, we need to use Navigation controller. Navigation controller manages a stack of View controller when we go from one view to another view.Navigation from one view controller to another view controller can be done like mentioned below.Step 1 − Create a View controller object.let vc = self.storyboard?.instantiateViewController(withIdentifier: "VC2ViewController") as! VC2ViewControllerIn this step we initialize an object of the type of our another view controller, to which we want to navigate. The identifier variable should be same as the identifier of our second view controller.Step 2 − Navigating to ... Read More

Use of 8259 in an 8086 Based System

Anvi Jain
Updated on 29-Jun-2020 14:00:58

2K+ Views

The interrupt requests are accepted by 8259 from eight interrupting devices on the pin ranging fromIR0 toIR7. After that, it identifies the priority interrupt having the highest request from the inputs which are active. It is possible for us to configure the 8259 for the mode of operation of "fixed priority" mode.Here, among the priorities, IR0 has the highest and IR7 has the lowest. If the three inputs IR2, IR4, and IR6 are in active state, then IR2 will have is the highest priority interrupt request than the other active requests. We can mask the requests of the interrupts by installing ... Read More

Description of 8253 Timer

Jennifer Nicholas
Updated on 29-Jun-2020 14:00:28

2K+ Views

As a DIP package Intel 8253 is a 24-pin programmable IC available. IChas three counters which work independently and whose width is of16-bits. In addition, we have a control port to decide what is the mode of working of the three counters. The physical and functional pin diagrams of them are indicated below.Fig.Diagram of 8253 pin basedFig.Pin diagram functionalVcc and GnThese are the Power supply and ground pins which 8253 uses +5V as power supplyD7-0For the communication of the processor there are eight functional pinsRD*This reads counter information it is active low pinWR*Writes control informationCS*It selects the chip which is ... Read More

Use Bold and Non-Bold Text in a UILabel in iOS

Vrundesha Joshi
Updated on 29-Jun-2020 13:59:33

4K+ Views

To use a Bold and a regular/Non-Bold text in a single UILabel, we can either use a storyboard editor to achieve the same, or we can do it programmatically. Let’s see both of them.Method One − Editing with StoryboardSelect the label you want to edit, go to it’s attribute inspector.From the first option Text, select Attributes instead of plain.Write the following text in the label “Bold Regular”Double Click on Bold to select it, and then right click on it to see more options.Select font > Bold from that option. It should do the task.Method Two − Programmatically Achieving the result.Add the ... Read More

Loop Through an ArrayList Using an Iterator in Java

George John
Updated on 29-Jun-2020 13:56:42

4K+ Views

An Iterator can be used to loop through an ArrayList. The method hasNext( ) returns true if there are more elements in ArrayList and false otherwise. The method next( ) returns the next element in the ArrayList and throws the exception NoSuchElementException if there is no next element.A program that demonstrates this is given as follows.Example Live Demoimport java.util.ArrayList; import java.util.Iterator; public class Demo {    public static void main(String[] args) {       ArrayList aList = new ArrayList();       aList.add("Apple");       aList.add("Mango");       aList.add("Guava");       aList.add("Orange");       aList.add("Peach");   ... Read More

Loop Through a HashMap Using an Iterator in Java

Ankith Reddy
Updated on 29-Jun-2020 13:55:50

251 Views

An Iterator can be used to loop through a HashMap. The method hasNext( ) returns true if there are more elements in HashMap and false otherwise. The method next( ) returns the next key element in the HashMap and throws the exception NoSuchElementException if there is no next element.A program that demonstrates this is given as follows.Example Live Demoimport java.util.HashMap; import java.util.Iterator; import java.util.Map; public class Demo {    public static void main(String[] args) {       Map student = new HashMap();       student.put("101", "Harry");       student.put("102", "Amy");       student.put("103", "John");       ... Read More

Use Iterator to Remove an Element from a Collection in Java

Arjun Thakur
Updated on 29-Jun-2020 13:54:59

19K+ Views

An element can be removed from a Collection using the Iterator method remove(). This method removes the current element in the Collection. If the remove() method is not preceded by the next() method, then the exception IllegalStateException is thrown.A program that demonstrates this is given as follows.Example Live Demoimport java.util.ArrayList; import java.util.Iterator; public class Demo {    public static void main(String[] args) {       ArrayList aList = new ArrayList();       aList.add("Apple");       aList.add("Mango");       aList.add("Guava");       aList.add("Orange");       aList.add("Peach");       System.out.println("The ArrayList elements are: ");     ... Read More

Iterate Through a LinkedList Using an Iterator in Java

Chandu yadav
Updated on 29-Jun-2020 13:53:57

6K+ Views

An Iterator can be used to loop through an LinkedList. The method hasNext( ) returns true if there are more elements in LinkedList and false otherwise. The method next( ) returns the next element in the LinkedList and throws the exception NoSuchElementException if there is no next element.A program that demonstrates this is given as follows.Example Live Demoimport java.util.LinkedList; import java.util.Iterator; public class Demo {    public static void main(String[] args) {       LinkedList l = new LinkedList();       l.add("John");       l.add("Sara");       l.add("Susan");       l.add("Betty");       l.add("Nathan");   ... Read More

Advertisements