To replace a character in objective C we will have to use the inbuilt function of Objective C string library, which replaces occurrence of a string with some other string that we want to replace it with.To create a string in objective C we need to write −NSString *str = @"tutori@als";Now we have a choice of replacing characters in this string and creating new one, or modify this same string. In this example we will modify this string and print in the next line.str = [str stringByReplacingOccurrencesOfString:@"@" withString:@""]; NSLog(@”%@”, str);When we run the above code, str is replaced with “tutorials” ... Read More
To change the background color of a button in iOS application we need to access the property ‘ backgroundColor’ of the UIButton. We can do this in two ways, programmatically and using the storyboard.Method 1 − Using the storyboard editorAdd a button on your storyboard, select it Go to it’s attribute inspector and select 'Background' property to choose the color.Method 2 − Programmatically changing the backgroundCreate outlet of the button on the View Controller.In the viewDidLoad() or viewWillLayoutSubview() method add the code to change the background color.btn.backgroundColor = #colorLiteral(red: 0.4392156899, green: 0.01176470611, blue: 0.1921568662, alpha: 1)When we run the method ... Read More
Importing all methods from a module in Python is a bad idea because of the following reasons.It is difficult to find a parent module of the method which we used in the programs.We are not allowed to create our functions with the names of methods.Let's see an example. Below we write a function called add in the sample.py.## sample.py file def add(a, b): return a + bExampleSave the above file in the same directory as below Python file.## let's assume we have module called sample from sample import * def add(*nums): return sum(nums) print(add(1, 2, 3, 4, ... Read More
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
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
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
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
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
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
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP