Prevent Screen from Sleeping in iOS

Mohtashim M
Updated on 16-Dec-2019 12:28:43

358 Views

In this post we will be seeing how to prevent screen from sleeping in iOS.So, let’s get started.Copy the below line of code in viewDidLoad method in ViewController.Swiftoverride func viewDidLoad() {    super.viewDidLoad()    // Do any additional setup after loading the view, typically from a nib.    UIApplication.shared.isIdleTimerDisabled = true }Run the application, the application will never go in sleep mode.

Create Tab Bar Layout in an iOS App

Mohtashim M
Updated on 16-Dec-2019 12:27:33

354 Views

In this post we’re going to see how one can use tab bar layout in their application.As per apple’s documentation −A tab bar appears at the bottom of an app screen and provides the ability to quickly switch between different sections of an app. Tab bars are translucent, may have a background tint, maintain the same height in all screen orientations, and are hidden when a keyboard is displayed. A tab bar may contain any number of tabs, but the number of visible tabs varies based on the device size and orientation.You can read more about the same herehttps://developer.apple.com/design/human-interface-guidelines/ios/bars/tab-bars/So let’s ... Read More

Programmatically Restart an iOS App

Mohtashim M
Updated on 16-Dec-2019 12:24:41

1K+ Views

You cannot restart an iOS Application in any case, even if you’re able to do using some private api your application will be rejected by Apple and will not be considered for App store release.

Create a File, Write Data into It and Read Data from It on iOS

Mohtashim M
Updated on 16-Dec-2019 12:23:05

1K+ Views

Being a software developer we should be always aware of how to play with files, write to a file, read from the file and so on.In this post we are going to learn the same, we will be creating a file and writing the data to the file and later reading through the same file.So let’s get started, Step 1 − Create new Xcode Project → Single View Application → name it “ReadingWritingFile”Step 2 − Open ViewController.swift and add new function as show belowpublic func createAndWriteFile() { }Now we will create a file and will print the path of the ... Read More

Total Number of Elements in a Specified Dimension of an Array in C#

AmitDiwan
Updated on 16-Dec-2019 10:28:34

125 Views

To get the total number of elements in a specified dimension of an array, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       string[] products = new string[] { "Andy", "Mark", "Gary", "Andre"};       Console.WriteLine("One or more name begins with 'A'? = {0}",       Array.Exists(products, ele => ele.StartsWith("A")));       Console.WriteLine("Is the array having fixed size? = " + products.IsFixedSize);       Console.WriteLine("Is the array read only? = " + products.IsReadOnly);       Console.WriteLine("Is the array synchronized? = " + products.IsSynchronized); ... Read More

Set Capacity to Actual Number of Elements in ArrayList in C#

AmitDiwan
Updated on 16-Dec-2019 10:18:04

126 Views

To set the capacity to the actual number of elements in the ArrayList, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(String[] args) {       ArrayList list1 = new ArrayList();       list1.Add("A");       list1.Add("B");       list1.Add("C");       list1.Add("D");       list1.Add("E");       list1.Add("F");       list1.Add("G");       list1.Add("H");       list1.Add("I");       Console.WriteLine("Elements in ArrayList1...");       foreach (string res in list1) {          Console.WriteLine(res);     ... Read More

Search for Element and Return Last Occurrence Index in C#

AmitDiwan
Updated on 16-Dec-2019 10:13:38

211 Views

To search for an element matching the conditions and return the zero-based index of the last occurrence within the entire List, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    private static bool demo(int i) {       return ((i % 10) == 0);    }    public static void Main(String[] args) {       List list = new List();       list.Add(200);       list.Add(215);       list.Add(310);       list.Add(500);       list.Add(600);       Console.WriteLine("List elements...");       foreach (int i in ... Read More

Searching the Index of Specified Object in Collection in C#

AmitDiwan
Updated on 16-Dec-2019 10:10:07

163 Views

To search the index of specified object in Collection, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringCollection strCol = new StringCollection();       strCol.Add("Accessories");       strCol.Add("Books");       strCol.Add("Electronics");       strCol.Add("Books");       Console.WriteLine("StringCollection elements...");       foreach (string res in strCol) {          Console.WriteLine(res);       }       strCol.Insert(2, "Headphone");       Console.WriteLine("StringCollection elements...UPDATED");       foreach (string res in strCol) {          Console.WriteLine(res); ... Read More

Number of Elements Contained in the BitArray in CHash

AmitDiwan
Updated on 16-Dec-2019 10:04:35

105 Views

To get the number of elements contained in the BitArray, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       BitArray arr1 = new BitArray(5);       BitArray arr2 = new BitArray(5);       arr1[0] = false;       arr1[1] = false;       arr2[0] = false;       arr2[1] = true;       Console.WriteLine("BitArray1 elements...");       foreach (bool res in arr1) {          Console.WriteLine(res);       }       Console.WriteLine("BitArray2 elements...");     ... Read More

Check Whether a Thread is Alive in C#

AmitDiwan
Updated on 16-Dec-2019 10:00:54

596 Views

To check whether a thread is alive or not, the code is as follows −Example Live Demousing System; using System.Threading; public class Demo {    public static void Main() {       Thread thread = new Thread(new ThreadStart(demo1));       thread = Thread.CurrentThread;       Console.WriteLine("Is the thread alive? = "+thread.IsAlive);       ThreadPool.QueueUserWorkItem(new WaitCallback(demo2));       Console.WriteLine("Current state of Thread = "+thread.ThreadState);       Console.WriteLine("ManagedThreadId = "+thread.ManagedThreadId);       thread.IsBackground = true;       Console.WriteLine("Is the Thread a background thread? = "+thread.IsBackground);    }    public static void demo1() {     ... Read More

Advertisements