Month: September 2018
-
Swift: Type casting for Any and AnyObject
Any can represent an instance of any kind of type and AnyObject can represent an instance of a class type.
-
Swift: Type Cast operator
A constant or variable may refer to an instance of a subclass behind the scenes. In order to downcast them to their specific subclass , we can use the type cast operator ( as? or as!). As the downcast to a specific subclass may not succeed, the type cast operator comes in two forms. as? returns a optional value that […]
-
Swift: Layout Anchors
In general, Swift provides as with 11 layout anchors which can be configured to create constraints using auto layout programatically. They are divided into three groups as follows: Horizontal constraint centerXAnchor leadingAnchor trailingAnchor leftAnchor rightAnchor Vertical constraint centerYAnchor bottomAnchor topAnchor firstBAseLineAnchor lastBaseLineAnchor size-based constraint heightAnchor widthAnchor
-
Swift: How to create alerts using UIAlertController?
UIAlertController is an object for displaying alerts to the user. We can configure alerts and action sheets with a custom message for the user and actions from which to choose. After configuring the alert, we have to present it using present(_:animated:,completion:) method. UIAlertAction is used to define the type of actions to be associated with our alerts. addAction […]
-
Swift: Type check operator ‘is’ with example code
Type check operator ‘ is ‘is used to check whether an instance is of a certain subclass type. It will return true if that instance belongs to that subclass type and false otherwise.
-
Swift: Type casting
Type casting is used to check the type of an instance , to check whether a type conform to a protocol or to treat that instance as a different superclass or subclass from somewhere else in its own class hierarchy. Type casting in Swift is done by using is and as operators.
-
tvOS:How to create a loading document programatically?
We can create a loading template programatically using the following code.