iOS Interview Questions And Answers- Part I

Shashi Tiwari
3 min readMar 27, 2020

Hi everyone out there,

I am an iOS Developer, self taught also learnt basics with help of my sister. But with a lots of passion for apple devices (I hate coding in beginning) I started learning iOS. I recently completed 5 years of my job period, currently working with an IT company and looking for more exposure in my field.

I feel there are so many new developers out there giving interviews and test it’s exhausting so I thought I might add some value and help them with the basics of iOS to help them out finding a good job.

Here is a list of few question that I have been asked in interviews and you might also have been asked -

Ques: Difference between Synchronous and Asynchronous task?

Ans: Synchronous waits until the task end, Asynchronous executes task in background and inform when finished.

Ques: What is difference in Strong, Weak, Copy, Assign and Read-only?

Ans: These are property attributes define how memory for that property will be managed.

Strong, once defined reference count increased and will remain through the life of object. By default properties are strong.

Weak, pointing object but not increasing reference count; It set to nil if deallocated. To be used in parent child relationship —

  • Parent will be strong and child will be defined as weak.
  • Used on var and optional type.
  • Will be nil it not in use.

Copy, It copies the value while creation and prevent it’s value from changing.

Assign, same as weak but It doesn’t set nil if deallocated.

Read-only, can set the property initially but then it can’t be changed.

Ques: What is Completion Handler?

Ans: A completion handler is a closure, also know as completion blocks, callbacks.

Closure is a self contained blocks of functionality that can be passed around and used in code

Create:

func generalCompletionHandler (callBackBlock: () -> void) {

print(“completion handler block”)

}

Use:

override func viewDidLoad() {

super.viewDidLoad()

generalCompletionHandler {

print(“Do Something after completion”)

}

}

Ques: Difference between frame and bounds?

Ans: Frame of an UIView is it’s start points(x,y) and size (width, height) relative to it’s superview.

Bounds of an UIView is it’s location (x, y) and size(width, height) relative to its own coordinates (0,0)

Ques: What is retain cycle?

Ans: Objects hold strong reference to each other through-out the app life.

Ques: What is Responder chain?

Ans: Responder chain is a hierarchy of object to response receive events. Views are visual objects to create user interface of an application. All views are subclass of UIKIT.

UIWindow is subclass of UIView and root of the view hierarchy. UIResponder is superclass of UIView or UIViewController.

Ques: What is viewController lifecycle?

Ans: View lifecycle is life of a view from creation to end; defined in sequence :

  • viewDidLoad()
  • viewWillAppear()
  • viewDidAppear()
  • viewWillDisappear()
  • viewDidDisappear()

Ques: What is application lifecycle?

Ans: Application lifecycle is application states; Defined in sequence —

  • willFinishLaunchingWithOptions()
  • didFinishLaunchingWithOptions()
  • willEnterForeground()
  • didBecomeActive()
  • willResignActive()
  • didEnterBackground()
  • willTerminate()

Ques: What are application states?

Ans: There is 5 states of apps written in iOS App Programming Guidelines —

  • Not-running : App is not running.
  • Inactive : App is running in foreground but not receiving any events. It can be when a call or SMS arrived when app is open.
  • Active : App is running in foreground and receiving events.
  • Background : App is running in background and executing some code.
  • Suspended : App is in background but no code is being executed.

Ques: What is autolayout?

Ans: It dynamically calculates the size and position of all the view in a view hierarchy depends on the constraints provided to them.

--

--