Working with date and time can be tricky, I’ve seen new programmers struggling with date and time. In almost all the application you will be required to get the date and multiple operations are dependent on it.Here we will be seeing how to get the current date and time in swift.In this post we will be seeing how to get the current time and UTC time.For getting the UTC time, paste below code in playground.let utcDate = Date() print(utcDate)If you wish to get the time stamp of your location, paste the below code in playground.let dateObj = Date() let datetformatter ... Read More
Getting difference between two dates is easy. You should know how to play between the dates.We will be using DateFormatter class for formatting the dates.Instances of DateFormatter create string representations of NSDate objects, and convert textual representations of dates and times into NSDate objects.You can read more about it here https://developer.apple.com/documentation/foundation/dateformatterWe will also be using Calendar structure, apple has provided beautiful documentation of it, https://developer.apple.com/documentation/foundation/calendarSo let’s get started.Open Xcode, New Playground.Copy the below codeimport UIKit // create object of DateFormatter and Calendar let formatter = DateFormatter() let calendar = Calendar.current // specify the format, formatter.dateFormat = "dd-MM-yyyy" // specify the start ... Read More
As of now, there’s no way you can access both front and back cameras simultaneously. As both cameras have different session, as soon as one will start other session will die.As per the apple developer forum answered by Apple support team −“Apps cannot capture from the front and back cameras simultaneously. You can switch from one to the other (with a short delay between) but not both at the same time”
Knowing when the application is in foreground or in background is important as being an iOS developer we need to handle multiple events such as background downloads, events if the app comes to foreground.Here we will see how to check if the application is in background or foreground.We will be using Notification Center for that, To read more about it you can refer apple document. https://developer.apple.com/documentation/foundation/notificationcenterA notification dispatch mechanism that enables the broadcast of information to registered observers. We will be adding observer to the same and will be getting the call.Step 1 − Open Xcode → New Project → Single ... Read More
Table View is one of the most important and fundamental part of iOS application, Every iOS developer should be familiar with it.Almost every application you see in App store use table view.Table views on iOS display a single column of vertically scrolling content, divided into rows. Each row in the table contains one piece of your app’s content. For example, the Contacts app displays the name of each contact in a separate row, and the main page of the Settings app displays the available groups of settingsYou can read more about table view here, https://developer.apple.com/documentation/uikit/uitableviewIn this post we will see ... Read More
It is very important to know when user is pressing home key as it puts the application to background, here we will be seeing how to identify or get a call when user presses home key.In you AppDelegate.swift, there are delegates methods.Open your AppDelegate.swift and in applicationWillResignActive(_ application: UIApplication) and applicationDidEnterBackground(_ application: UIApplication), write print statement and put a breakpoint as shown.Run the application, once the app is launch tap the home button, applicationWillResignActive will be called and then applicationDidEnterBackground.
There will be instance where you might get a requirement to control / manipulate width and height the Alert while developing iOS application. If you’re not familiar with the same, it can trouble you.Here we will be seeing how to control the width and height of default alert box, For controlling the height and width we will be using NSLayoutConstraint.To read more about UIAlertController refer − https://developer.apple.com/documentation/uikit/uialertcontrollerIn this, we will be creating a new project where we will have a button, on tapping that button we will show alert with custom message.Step 1 − Open Xcode → New Project → Single ... Read More
The HTML DOM Clipboard event is used to provide information regarding modification of the clipboard. The events can be cut, copy and paste. The Clipboard event can be used to make your site more accessible i.e. giving user information on how the clipboard is being modified.PropertiesFollowing is the property for Clipboard event −PropertyDescriptionclipboardDataTo return an object containing the data affected by the clipboard operation(cut, copy or paste).EventsFollowing are the event types belonging to the Clipboard event −EventDescriptiononcopyThis event fires when the content of an element is copied by the user.OncutThis event fires when the user cuts the content of an ... Read More
The HTML DOM Caption object is associated with the HTML element. The element is used for setting caption (title) of the table and should be the first child of the table. You can access caption element using the caption object.PropertiesNote: The below property are not supported in the HTML5.Following is the HTML DOM Caption Object property −PropertyDescriptionAlignTo set or return the caption alignment.SyntaxFollowing is the syntax for −Creating a caption object −var x = document.createElement("CAPTION");ExampleLet us see an example for the HTML DOM Caption object − table, th, td { border: ... Read More
To verify whether a given String contains only characters −Read the String.Convert all the characters in the given String to lower case using the toLower() method.Convert it into a character array using the toCharArray() method of the String class.Find whether every character in the array is in between a and z, if not, return false.ExampleFollowing Java program accepts a String from the user and displays whether it is valid or not.import java.util.Scanner; public class StringValidation{ public boolean validtaeString(String str) { str = str.toLowerCase(); char[] charArray = str.toCharArray(); for (int i ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP