Qs Flashcards
What is iOS Swift?
Swift is a compiled and new programming language evolved by Apple Inc in June 2014 in order to develop apps for mobile and desktop. This language works for watchOS, macOS, iOS, and tvOS.
What are the advantages of using Swift?
Open-source language: The Swift programming language has been created as an open-source and is being open to everyone, this makes it simple for the program to upgrade all the source codes, email lists and bug tracker at regular intervals.
Easy to learn and maintain: Swift programing language is more simple and accurate when compared to C/C++. Apple evolved its programing language to be easy to use and syntaxes are taken from programming languages such as C#, Python, and Ruby. These simple syntax of this programing language make it more meaningful. In swift, all the content of the implementation (.m) and header (.h) files are combined in a single file that is (.swift).
Closures: Closures are self-contained blocks of functionality that can be passed around and used in our code.
Supports dynamic libraries: Dynamic libraries are the executable chunks of the code that can be connected to an app. This feature allows the latest swift programing language. In swift, dynamic libraries are directly uploaded to the memory, thereby resulting in deduction down on the initial size of the app and finally increases app performance.
Optional types: An optional in swift is a type that can be held either as a value or not. To declare an optional, we can use a question “?” mark.
What are the most important features of swift?
More impressive structs and enums
Protocol oriented
Optional Types
Type Safety and Type inference language
Not required to use semicolons
Enforced initializers
Safe by default
Less code, fewer files
Forced Unwrapping
Tuples
Closures
Much faster when compared to other languages.
What type of objects are basic data types in swift?
Swift uses a standard set of basic data types for different purposes such as Boolean values, numbers, and strings.
Int: int is used to store the integer value.
Double and Float: Double and Float in swift are considered when while working with the decimal numbers.
Bool: The bool type is used to store the Boolean value. In swift, it uses true and false conditions.
String: In String literals, the user defines the text that is enclosed by double quotes in Swift.
Arrays: Arrays are the collection of list items.
Dictionaries: A dictionary is an unordered collection of items of a particular type that is connected with a unique key.
What is init() in Swift?
Initialization is a process of preparing an instance of an enumeration, structure or class for use.
Initializers are also called to create a new instance of a particular type. An initializer is an instance method with no parameters. Using the initializer, we can write the init keyword
What are the control transfer statements that are used in iOS swift?
The control transfer statements that are used in iOS swift include:
Return
Break
Continue
Fallthrough
Which JSON framework is supported by iOS?
SBJson framework is supported by iOS. SBJson framework provides additional control and a flexible API which makes JSON handling easier. It is a well and highly flexible framework that supports the flexible functioning of APIs.
What is PLIST in iOS?
PLIST stands for Property List. PLIST is basically a dictionary of value and keys that can be stored in our file system with a .plist file extension. The property list is used as a portable and lightweight means to store a lesser amount of data. They are normally written in XML.
Different types of property lists are mentioned below:
Binary Property List
XML Property List
ASCII Legacy Property List
What is a dictionary?
Dictionaries are an association of an unordered collection of key-value pairs. Each value is associated with a unique key, which is a hashable type such as a number or string. We can use the dictionary concept in swift programming language whenever we want to obtain the values based on a key value.
What is a Protocol in swift?
The protocol is a very common feature of the Swift programming language and the protocol is a concept that is similar to an interface from java. A protocol defines a blueprint of properties, methods, and other requirements that are suitable for a particular task.
In its simplest form, the protocol is an interface that describes some methods and properties. The protocol is just described as the properties or methods skeleton instead of implementation. Properties and methods implementation can be done by defining enumerations, functions, and classes.
Protocols are declared after the structure, enumeration or class type names. A single and multiple protocol declaration can be possible. Multiple protocols are separated by commas.
What is a delegate in swift?
Delegate is a design pattern, which is used to pass the data or communication between structs or classes. Delegate allows sending a message from one object to another object when a specific event happens and is used for handling table view and collection view events.
Delegates have one to one relationship and one to one communication.
What is a GUARD statement? What is the benefit of using the GUARD statement in swift?
A GUARD statement is used to transfer the program control out of the scope when one or more conditions are not met. Using this statement helps in avoiding the pyramid of doom.
What are the collection types that are available in swift?
There are three primary collection types that are available in swift for storing a collection of values. They are dictionaries, sets, and arrays
Arrays: Arrays is an ordered collection of values, which is stored in the same type of values in an ordered list.
Sets: Sets are an unordered collection of unique values, which are stored in a distinct value of the same type in a collection without any defined ordering.
Dictionaries: Dictionaries are an unordered collection of Key and value pair associations in an unordered manner
What is “defer”?
The “defer” is a keyword that provides a block of code that can be executed while the execution is leaving the current scope.
What is Tuple? How to create a Tuple in swift?
A tuple is a group of different values in a single compound value. It is an ordered list of elements. There are two ways of accessing the object data in a tuple i.e. by name or by position.
In swift, a tuple can consist of multiple different types. It can support two values i.e. one of integer type, and the other of a string type. It is a legal command.
What is the difference between Array and NSArray?
The difference between Array and NSArray are given below:
An array can hold only one type of data, whereas NSArray can hold different types of data.
An array is a value type, whereas NSArray is an immutable reference type.