iOS Interview Questions And Answers

Tram Ho

I. Introduction

The Swift language is only four years old, but it has become the default language for iOS programming. As Swift evolved to version 5.0, it has become a complex and powerful language encompassing functional and object-oriented programming models. Each new version brings more improvements and improvements.

Below I would like to raise a few questions you may encounter when going to a job interview, or you can also read them to consolidate your knowledge. These questions are not thought up by me, but I read it by chance on . This article is for reference only, consolidating knowledge for fun, if you go to the interview, but the employer does not ask any questions here, it is not to blame you! =))

II. Content Questions

What is Optional?

  • Is a data type that can hold nil value

What is Optional Binding?

  • Is a method for working with the optional data type and securing the return data using if let or guard let.

What is Optional Chaining?

  • Is a data string in which at least 1 element in the string is of type Optional

Distinguishing Optional and Implicitly Unwrapped Optional?

  • Optional and Implicitly Unwrapped Optional are both Optional so they can both accept nil values. But unlike Optional, every time a variable is declared as Implicitly Unwrapped Optional, it is automatically Force Unwrap. So when calling an Implicitly Unwrapped Optional variable while it is carrying nil, the app will crash. Therefore, with these variables we also have to test it before using it like using an Optional variable

How do I automatically Force Unwrap a variable every time I call it?

  • var optional: Int!

Compare Computational Properties and Storage Properties?

  • Computed properties, a type of property that doesn’t actually store value, instead provides getter and optional setter to get and set properties and assign values ​​indirectly.
  • A stored property, class, structure, and enums are a constant or variable stored as part of an instance that belongs to a particular class or structure. Stored properties can be variable stored properties (with the var keyword) or constant stored properties (with the let keyword).

Explain var xx: Int {willSet {is different from var yy: Int {didSet { ?

  • With var xx: Int {willSet {:, then execute the method before assigning the value.
  • With var yy: Int {didSet {:, then execute the methods as soon as the variable is assigned a value

How is Array different from Dictionary?

  • Array is concerned with order, while Dictionary is not concerned with order

How is Array different from Set?

  • Array cares about order, Set doesn’t care about order and elements in the set don’t repeat (so the elements in Set must implement Equatable)

How do I create a variable that is only initialized when it is first called?

  • – ‘Lazy var XXX:’ Data type ‘= {return’ Value corresponding to data type ‘} ()

How is GET different from POST?

  • Get: The passed parameter is embedded in the url,
  • Post: Parameter passed on is attached to Body

Comparison between Merge and Rebase?

  • Merge is to merge all changes of the source branch into a commit merge in the current branch.
  • Rebase is to pass all commits of the source branch to the bottom of the current branch, then apply each commit in the current branch above those commits.

How is Revert different from reset?

  • Reset is to delete any changes from the current point in time to the selected commit. Revert is a commit that reverses any changes in the selected commit

What is Cherry Pick?

  • Copy the changes from a commit and apply it to the current branch

What is Stash?

  • Stores changes in a clipboard

What is Merge Request?

  • Make a request to Group all changes from another branch into a commit on the current target branch

What is the Pull To Request?

  • Make a request to merge all changes from one branch on another repo into a commit on the current branch of the target repo.

Compare Hard Reset, Soft Reset

  • Hard reset is to delete all commits to the selected commit.
  • Soft reset is to delete commits but keep the changes.

What are the ways to transfer data? ‘- There are 06 ways to transfer data:

  1. Segue to transmit data. Unwind Segue to return data
  2. Delegate
  3. Closure
  4. NotificationCenter.
  5. Singleton (A global variable used throughout the application declared as static).
  6. UserDefault, CoreData, Reaml … use save data to DataBase and load it up.
  7. KVO

What is Singleton and when is it used?

  • Definition: Singleton is a pattern that ensures that a class has a single instence that provides a common interface for accessing that class. Example:

Presenting the life cycle of a ViewController (ignoring LoadView)?

  • Viewcontroller lifecycle: -ViewDidload -> ViewwillAppear -> ViewdidAppear -> ViewwilldisAppear -> ViewdidDisAppear Detail: -VIewdidLoad: Called when Viewcontroller has been loaded into memory. (Set up data or initialize object, UI on screen) -ViewwillAppear : called before a view shows up. -ViewdidAppear: call when view is shown on screen -ViewwillDisappear: Call when a view is hidden from screen and animation when hidden view. -VIewDidDisAppear: call when a view is hidden from the screen

Presenting the life cycle of an App?

  • First go to DidFinishLaunching -> (WillEnterForcegrounh -> DidBecomeActive -> WillResignActive -> DidEnterBackgrouch) -> WillTerminate

How is Unowned VS Weak?

  • Unowned is a Non-Optional. Its lifecycle coincides with the Object life cycle. That means it is created with the Object, and is released when the object is released. No object can point to it, so it is named Unowned.
  • Weak is an Optional variable. It can be instantiated later, and can persist after the object pointing to it has been released.

For now, I will find out later, I will write more ….

Share the news now

Source : Viblo