Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Category of Data Types in Swift?

Answer»

Category of DATA Types in Swift?
There are mianly two types of data types in Swift
(A)Value TYPE:-
(1)Arrays, Booleans, Characters, Dictionaries, Floating-Points, Int, Strings and Tuples (These are IMPLEMENTED as structures)
(2)Optionals (These are implemented as Enumerations)
(B)Reference Types:-
(1)CLASSES
(2)Functions and Closures

2.

Why we use Swift Programming Language?

Answer»

Why we USE SWIFT Programming Language?
Swift is a programming language and a SYSTEM for creating application for iOS and OS X. And it is USES as innovative programming language for Cocoa and Cocoa TOUCH.

3.

Functions definition in Swift Programming Language?

Answer» FUNCTIONS definition in Swift PROGRAMMING Language?
When we combined some set of codes to perform some specific task it is called as function in Swift. Here is Swift language we pass LOCAL and global parameter values inside function when we do a function call. Functions are categorized in below two TYPES:-
(1)User Defined Functions
(2)Built-in Functions (This is also called LIBRARY function)
4.

Write code to use function AsyncAfter and afterDelay to delay or wait time in Swift?

Answer»

Write CODE to use function AsyncAfter and afterDelay to delay or WAIT TIME in SWIFT?
(1)Here in first function we use function using AsyncAfter. Below is the block of code after a time delay by using asyncAfter:-

let DelayInseconds = 4.0
DispatchQueue.main.asyncAfter(deadline: .now() + DelayInseconds)
{
print("This message display after 4 seconds")
// Put any custom code here
}


(2)Here we call a function after a Wait time. Here function is call after certain period of time:-

let DelayInseconds = 4.0
perform(#selector(delayedFunction), with: nil, afterDelay: DelayInseconds)
objc func delayedFunction()
{
print("This message display after 4 seconds")
}

5.

Set custom or some specific background colors in Swift Code?

Answer»

Set custom or some specific background colors in Swift Code?
Below are the two WAY to set background color in Swift:-
(1)To change the background color to green in a Swift UIViewController
self.view.backgroundColor = UIColor.green
(2)To set UI color in Swift
let whiteColor = UIColor(rgb: 0xFFFFFF)
self.view.backgroundColor = whiteColor

6.

What do you mean by nil-coalescing operator?

Answer»

What do you mean by NIL-coalescing operator?
It is like a OPTIONAL conditional operator like if some value is nil then output is some other values. To UNDERSTAND this we will TAKE a below example which will help you to understand the syntax for nil-coalescing operator.
nil-coalescing operator(x ?? y)
Here in above code if x have some value then it will return value of x but if x is nill then it will return value of y here.
And it is a shortut of below condition operator code:-
x!= nil ? x! :y