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.
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
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.
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
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
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
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
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
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
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP