Questions, Tips and Tricks to clear iOS Interview Questions
Photo from Unsplash
If you did not have a chance to read the first part of this blog, please read here
func someFunction() -> String {
defer { return "World" }
return "Hello"
}
print(someFunction())
Options
var employeeSalary = 20
func updateEmployeeSalary() {
employeeSalary = 70
defer { employeeSalary = 30 }
defer { employeeSalary = 40 }
defer { employeeSalary = 50 }
employeeSalary = 50
}
updateEmployeeSalary()
print(employeeSalary)
Options
var a: String = "a"
var b: String! = "b"
var c: String? = "c"
a = c // 1
b = c // 2
c = b // 3
Options
In the below given horizontal StackView. Which of the following is true?
Options
arranged in a horizontal StackView, Which among the following represents Distribution set to fillProportionally .
class WhiteHouse {
weak var pentagon: Pentagon?
deinit {
print("White House deinitialized")
}
}
class Pentagon {
weak var whiteHouse: WhiteHouse?
deinit {
print("Pentagon deinitialized")
}
}
var a = WhiteHouse()
a.pentagon = Pentagon()
weak var b = Pentagon()
b?.whiteHouse = a
Options
class Kondana<T: Equatable> {
var dictDataHolder = [String: T]()
func add(value: T?, using key: String) -> T? {
self.dictDataHolder[key] = value
return value
}
}
var fortOne = Kondana<String>()
let value = fortOne.
print(value)
Options
var motive = "Sip"
let userMotive = { [motive] in
print(motive)
}
motive = "Lump Sum"
print(userMotive())
struct Person {
var contact: Contact
init(contact: Contact) {
self.contact = contact
}
}
class Contact {
var phoneNumber: Int
init(phoneNumber: Int) {
self.phoneNumber = phoneNumber
}
}
let contact = Contact(phoneNumber: 1800)
var vijay = Person(contact: contact)
let ajith = vijay
vijay.contact.phoneNumber = 1234
print(ajith.contact.phoneNumber)
print(vijay.contact.phoneNumber)
protocol SomeProtocol {
func someFunction()
}
extension SomeProtocol {
func someOtherFunction() {
print("SomeProtocol: Some Other Function")
}
}
struct SomeStruct: SomeProtocol {
func someFunction() {
print("Some Function")
}
func someOtherFunction() {
print("SomeStruct: Some Other Function")
}
}
let someStruct: SomeProtocol = SomeStruct()
print(someStruct.someFunction())
print(someStruct.someOtherFunction())
Options
1 2 3 4 5 6 7 8 9 10 End of the World!
let firstQueue = DispatchQueue (label: "First Queue")
let globalQueue = DispatchQueue.global()
let parentQueue = DispatchQueue (label: "Parent Queue")
color
:
enum Color: String {
case red
case green
case blue
}
let color = Color(rawValue: "yellow")
Options
What is the center
of outerView
(x: ?, y: ?)
What is the centre
of innerView
(x: ?, y: ?)
What are the bounds
of innerView
(x: ?, y: ?, width: ?, height: ?)
What are the bounds
of outerView
(x: ?, y: ?, width: ?, height: ?)
What is the frame
of the innerView
(x: ?, y: ?, width: ?, height: ?)
final class SingleTon {
static let shared = SingleTon()
private var viewControllers = [UIViewController]()
private init() { }
func add(vc: UIViewController) {
viewControllers.append(vc)
}
func remove(vc: UIViewController) {
if let index = viewControllers.firstIndex(of: vc) {
viewControllers.remove(at: index)
}
}
}
final class SomeViewController: UIViewController {
init() {
super.init(nibName: nil, bundle: nil)
SingleTon.shared.add(vc: self)
}
}
Answers are not provided intentionally 😜, to make you try and understand personally, you can add your answers/clarifications in the comment section.
This is a free third party commenting service we are using for you, which needs you to sign in to post a comment, but the good bit is you can stay anonymous while commenting.