Qs Flashcards

1
Q

What is iOS Swift?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the advantages of using Swift?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the most important features of swift?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What type of objects are basic data types in swift?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is init() in Swift?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the control transfer statements that are used in iOS swift?

A

The control transfer statements that are used in iOS swift include:

Return
Break
Continue
Fallthrough

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which JSON framework is supported by iOS?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is PLIST in iOS?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a dictionary?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a Protocol in swift?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a delegate in swift?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a GUARD statement? What is the benefit of using the GUARD statement in swift?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the collection types that are available in swift?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is “defer”?

A

The “defer” is a keyword that provides a block of code that can be executed while the execution is leaving the current scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Tuple? How to create a Tuple in swift?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between Array and NSArray?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the difference between class and structure?

A

The difference between class and structure are given below:

Classes are reference types, whereas structs are value types.

Classes can be built on other classes, whereas struct cannot inherit from another struct.

Classes have an inheritance, whereas structs cannot have an inheritance.

In class, we can create an instance with “let” keywords and attempt to mutate its property, whereas there is no Mutability in Structs.

Classes have Type Casting, whereas struct doesn’t have Type Casting.

18
Q

What are the best ways of achieving concurrency in iOS?

A

The three best way to achieve concurrency in iOS are given below:

Dispatch queues
Threads
Operation queues

19
Q

How to pass the data between view controllers?

A

There are three ways to pass the data between view controllers as shown below.

Using Segue, in prepareForSegue method (Forward).

Setting the variable directly (Backward).

Using Delegate (Backward).

20
Q

How can we define a base class in swift?

A

In a swift programming language, classes are not inherited from the base class. The classes are defined by the developer without specifying the superclass and it will become the base class automatically.

21
Q

Who calls the main function of our app during the app launch cycle?

A

The main thread calls the main function of our app. During the app launching cycle, the system will create a main thread for the app and call the app main function on that main thread.

22
Q

What are UI elements?

A

Images, Buttons, labels, text fields, and any other elements that are visible to the user within the application are called UI elements.

23
Q

Which is the superclass of all the view controller objects?

A

UIViewController class is the superclass of all the view controller objects. The functionality for presenting them, loading views, rotating them is a response to the device rotations. All the standard system behavior is provided by the UIViewController class.

24
Q

What are the new feature in Swift 4.0?

A

The new features in swift 4.0 are given below:

Faster and easier to use strings that keep Unicode correctness.

Tuples and multiple return values.

Native error handling using throw/try/catch.

Extends to support serialization to a struct.

25
Q

What are the source items used by Xcode?

A

Xcode uses four different types of source items as mentioned below:

Framework
Source Group
Source File
Source Folder

26
Q

What are the different ways to pass data in swift?

A

There are several ways to pass data in swift such as KVO, Delegate, NSNotification & Callbacks, Target-Action, etc.

KVO, which stands for Key-Value Observing, is one of the techniques for observing the program state changes available in Objective-C and Swift. The concept is simple: when we have an object with some instance variables, KVO allows other objects to establish surveillance on changes for any of those instance variables.

27
Q

Explain the usage of Class and benefits of Inheritance.

A

Reuse implementation

Subclass provides dynamic dispatch.

Subclass provides the reuse interface.

Modularity

Overriding provides the mechanism for customization.

28
Q

Explain some Common features of Protocols & Superclasses.

A

Interface reuse.

Implementation reuse.

Supporting modular design.

Provides points for customization.

29
Q

What is Optional chaining?

A

Optional chaining is a useful process which we can use in combination with the optional to call the methods, properties, and subscripts on the optionals and these values may or may not be nil. In this process, we may try to retrieve a value from a chain of the optional values.

  • If the optional contains a value, then calling the subscript, method or property of an optional will return a value.
  • If optional is nil, then calling the subscript, method and property will return nil.
30
Q

What is Optional binding?

A

Optional Binding concept is used to find out whether an optional contains a value, and it makes that value available as a variable or temporary constant. We use an optional binding concept to check if the optional contains a value or not.

Optional binding can be used with the condition (if and while) statements to check for a value inside an optional.

31
Q

What are the Higher-Order functions in swift?

A

Map: Transform the array contents.

Reduce: Reduce the values in the collection to a single value.

Sort: Sorting the arrays.

Filter: Transform the array contents.

32
Q

Explain some design patterns which we normally use during the app development.

A

Behavioral: Memento, and Observer.

Creational: Builder, Factory, and Singleton.

Structural: Façade, Adapter, and Decorator.

33
Q

What are the various ways to unwrap an optional in swift?

A

Guard statement: safe.

Forced unwrapping: using “!” operator, unsafe.

Optional binding: safe.

Optional pattern: safe.

Nil coalescing operator: safe.

Implicitly unwrapped variable declaration: unsafe in many cases.

Optional chaining: safe.

34
Q

What mechanism does iOS support for multi-threading?

A

NSThread: It can create a low-level thread which can be started by using the “start” method.

NSOperationQueue: It allows a pool of threads to be created and is used to execute “NSOperations” in parallel

35
Q

What is Swift module?

A

A module is a single unit of code distribution.

A framework or application is built and shipped as a single unit and that can be imported by another module using the swift import keyword.

Each build target in the Xcode tool is treated as a separate module in swift.

36
Q

Explain Core Data.

A

Core data is one of the most powerful frameworks provided by Apple for macOS and iOS apps. Core data is used for handling the model layer object in our applications. We can treat Core Data as a framework to filter, modify, save, track the data within the iOS apps. Core Data is not a relational database.

Using core data, we can easily map the objects in our app to the table records in the database without knowing any SQL. Core data is the M in MVC structure.

  • Effective integration with the iOS and macOS toolchains.
  • Organizing, filtering, and grouping data in memory and in the UI (User Interface).
  • Automatic support for storing objects.
  • Automatic validation of property values.
  • First framework for managing an object graph.
  • Core Data framework for managing the life cycle of the object in the object graph.
37
Q

Explain the Grand Central Dispatch (GDC).

A

GCD (Grand Central Dispatch) is a low-level API for managing the concurrent operations. This concept is used to help in improving application performance. This process is used to manage multiple tasks at the same time. Grand Central Dispatch (GCD) is the most useful API for multitasking with Async and Sync programming in iOS.

  • Dispatch Queue: The Dispatch Queue manages the task in FIFO(First In First Out) order. Dispatch queues are thread-safe as we can access them from multiple threads simultaneously.
  • Concurrent: This process has started multiple tasks at the same time but is not sure of the termination at the same time. It can be finished in any order. They execute one or more tasks at the same time concurrently. The task is completed according to the complexity, and not by the order in the queue.
  • Serial: Only one task will execute at a time. It can be used to synchronize access to a specific resource.
  • Sync: A synchronous function has return control to the caller after the task is complete.
  • Async: An asynchronous function returns immediately, by ordering the task to start but will not wait for it to complete.
38
Q

Explain MVC structure.

A

MVC stands for the model view controller. MVC is a powerful software architecture pattern for using developing apps.

MVC builds on top of the Object-Oriented Programming concepts. It structures the flow of data and interaction in our app. Model-View-Controller is an important fundamental concept to be understood in iOS development. Many iOS frameworks, like UIKit, Cocoa Touch, use the MVC pattern for messaging and structured data flow.

Model-View-Controller is used to pass the data from one part of our app to another.

Its a design pattern used to assign objects in an application in any one of the three roles:

Model: Model is a wrapper of data. Model is a representation of our app data and it holds the information to a specific user like birthdate, username, etc. The model manages the application state. This also includes writing and reading data. The Model encapsulates an individual set of data and applies some logic to manipulate that data.

View: View is a representation of a UI (User Interface). A View is an object that the visible to the user and it interacts with a user interface (UI).

Controller: Controller is an intermediary between the View and the Model. The controller controls all the logic that goes between the Model and the View. Its inter-communicates messages between the Model and the View, and vice versa.

39
Q

what is a reuse identifier?

A

The reuse identifier is associated with a UITableViewCell object that the table-view’s delegate creates with the intent to reuse it as the basis (for performance reasons) for multiple rows of a table view. It is assigned to the cell object in init(frame:reuseIdentifier:) and cannot be changed thereafter.

40
Q

Explain API’s

A

API stands for Application Programming Interface. It is a programmatic way to be able to access functions and data of other apps. … So API’s allows you to access a huge amount of data and built apps that rely on existing systems like facebook or twitter.

REST APIs or RESTful web services in layman’s terms are the way that the mobile apps or websites communicate and transmit data to servers and vice-versa. There are a set HTTP Requests posting and getting data to and from servers over internet.

41
Q

Explain the different types of iOS Application States.

A

Not running state: when the app has not been launched or was running but was terminated by the system.

Inactive state: when the app is running in the foreground but is currently not receiving events. An app stays in this state briefly as it transitions to a different state. The only time it stays inactive is when the user locks the screen or the system prompts the user to respond to some event such as a phone call or SMS message.

Active state: when the app is running in the foreground and is receiving events. This is the normal mode for foreground apps.

Background state: when the app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time can remain in this state for some time. Also, an app being launched directly into the background enters this state instead of the inactive state.

Suspended state: A suspended app remains in memory but does not execute any code. When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.