50 iOS Interview Questions And Answers Part 3

Image for post
Image for post

Hello, Part 3 is ready! Check out Part 1 and Part 2 if you haven’t already :)

1- What is Nil Coalescing & Ternary Operator?

It is an easy return an unwrapped optional or a default value. If we do not have a value, we can set zero or default value.

2- What kind of JSONSerialization have ReadingOptions?

  • mutableContainers Specifies that arrays and dictionaries are created as variables objects, not constants.
  • mutableLeaves Specifies that leaf strings in the JSON object graph are created as instances of variable String.
  • allowFragments Specifies that the parser should allow top-level objects that are not an instance of Array or Dictionary.

3- How can you prevent a user from doing said action more than once on their device?

Apple has introduced DeviceCheck in iOS 10. This API allows us to access per-device, per-developer data in an iOS device. The solution is better than UserDefaults or Advertising Identifier. DeviceCheck allows us to store a boolean value.

4- What is DispatchGroup?

allows for aggregate synchronization of work. We can use them to submit multiple different work items and track when they all complete, even though they might run on different queues. This behavior can be helpful when progress can’t be made until all of the specified tasks are complete. — Apple’s Documentation

The most basic answer: If we need to wait on a couple of asynchronous or synchronous operations before proceeding, we can use

5- What is RGR ( Red — Green — Refactor)?

Image for post
Image for post

Red, Green and Refactor are stages of the TDD (Test Driven Development).

  1. Red: Write a small amount of test code usually no more than seven lines of code and watch it fail.
  2. Green: Write a small amount of production code. Again, usually no more than seven lines of code and make your test pass.
  3. Refactor: Tests are passing, you can make changes without worrying. Clean up your code. There are great workshop notes here.

6- Where do we use Dependency Injection ?

We use a storyboard or xib in our iOS app, then we created IBOutlets. IBOutlet is a property related to a view. These are injected into the view controller when it is instantiated, which is essentially a form of Dependency Injection.

There are forms of dependency injection: constructor injection, property injection and method injection.

7- Please explain types of notifications.

There are two type of notifications: Remote and Local. Remote notification requires connection to a server. Local notifications don’t require server connection. Local notifications happen on device.

8- When is a good time for dependency injection in our projects?

There is a few guidelines that you can follow.

Rule 1. Is Testability important to us? If so, then it is essential to identify external dependencies within the class that you wish to test. Once dependencies can be injected we can easily replace real services for mock ones to make it easy to testing easy.

Rules 2. Complex classes have complex dependencies, include application-level logic, or access external resources such as the disk or the network. Most of the classes in your application will be complex, including almost any controller object and most model objects. The easiest way to get started is to pick a complex class in your application and look for places where you initialize other complex objects within that class.

Rules 3. If an object is creating instances of other objects that are shared dependencies within other objects then it is a good candidate for a dependency injection.

9- What kind of order functions can we use on collection types ?

  • : Returns an array of results after transforming each element in the sequence using the provided closure.
  • : Returns an array of elements that satisfy the provided closure predicate.
  • : Returns a single value by combining each element in the sequence using the provided closure.
  • : Returns an array of the elements in the sequence sorted based on the provided closure predicate.

To see all methods available from , take a look at the Sequence docs.

10- What allows you to combine your commits ?

11- What is the difference ANY and ANYOBJECT ?

According to Apple’s Swift documentation:

  • Any can represent an instance of any type at all, including function types and optional types.
  • AnyObject can represent an instance of any class type.

Check out for more details.

12- Please explain SOAP and REST Basics differences ?

Both of them helps us access Web services. SOAP relies exclusively on XML to provide messaging services. SOAP is definitely the heavyweight choice for Web service access. Originally developed by Microsoft.

REST ( Representational State Transfer ) provides a lighter weight alternative. Instead of using XML to make a request, REST relies on a simple URL in many cases. REST can use four different HTTP 1.1 verbs (GET, POST, PUT, and DELETE) to perform tasks.

13- What is your favorite Visualize Chart library?

Charts have support iOS,tvOS, OSX The Apple side of the cross-platform MPAndroidChart.

Core Plot is a 2D plotting framework for macOS, iOS, and tvOS

TEAChart has iOS support

A curated list of awesome iOS chart libraries, including Objective-C and Swift

14- What is the difference Filter and Map Function?

Map, we pass in a function that returns a value for each element in an array. The return value of this function represents what an element becomes in our new array.

Filter, we pass in a function that returns either true or false for each element. If the function that we pass returns true for a given element, then the element is included in the final array.

15- What is CoreData ?

Core data is an object graph manager which also has the ability to persist object graphs to the persistent store on a disk. An object graph is like a map of all the different model objects in a typical model view controller iOS application. CoreData has also integration with Core Spotlight.

But Core Data is not thread safe, meaning that, if you load a managed object on one thread, you can’t pass it to another thread and use it safely. This becomes an issue when we want to start introducing threading for performance, so we have two choices.

The first is to keep everything on the main thread, which just means it’s single threaded. Or the second means making changes on background threads and passing managed object IDs and then loading those objects again on the main thread, but that would mean that you’re on the main thread, which puts us right back where we started. Both of these kind of ruin the point of using threading within Core Data and they can add a lot of complexity to the data layer.

There’s also another option for that and it’s to convert the managed object to a plain old Swift object, or a POSO.

16- Could you explain Associatedtype ?

If you want to create Generic Protocol we can use associatedtype. For more details check this out.

17- Which git command saves your code without making a commit ?

18- Explain Priority Inversion and Priority Inheritance.

If high priority thread waits for low priority thread, this is called Priority Inversion. if low priority thread temporarily inherit the priority of the highest priority thread, this is called Priority Inheritance.

19- What is Hashable?

Hashable allows us to use our objects as keys in a dictionary. So we can make our custom types that can be compared for its equality using it’s

20- When do you use optional chaining vs. if let or guard?

We use optional chaining when we do not really care if the operation fails; otherwise, we use or . Optional chaining lets us run code only if our optional has a value.

Using the question mark operator like this is called optional chaining. Apple’s documentation explains it like this:

Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional that might currently be nil. If the optional contains a value, the property, method, or subscript call succeeds; if the optional is nil, the property, method, or subscript call returns nil. Multiple queries can be chained together, and the entire chain fails gracefully if any link in the chain is nil.

21- How many different ways to pass data in Swift ?

There are many different ways such as Delegate, KVO, Segue, and NSNotification, Target-Action, Callbacks.

22- How do you follow up clean code for this project ?

I follow style guide and coding conventions for Swift projects of Github and SwiftLint.

23- Explain to using Class and Inheritance benefits

  • With Overriding provides a mechanism for customization
  • Reuse implementation
  • Subclassing provides reuse interface
  • Modularity
  • Subclasses provide dynamic dispatch

24- What’s the difference optional between and ?

There is no difference. ( for short) is the correct way of initializing an optional variable lacking a value, whereas is just syntactic sugar for . Check this out.

25- What is GraphQL ?

GraphQL is trying to solve creating a query interface for the clients at the application level. Apollo iOS is a strongly-typed, caching GraphQL client for iOS, written in Swift.

26- Explain Common features of Protocols & superclasses

  • implementation reuse
  • provide points for customization
  • interface reuse
  • supporting modular design via dynamic dispatch on reused interfaces

27- What is Continuous Integration ?

Continuous Integration allows us to get early feedback when something is going wrong during application development. There are a lot of continuous integration tools available.

Self-hosted server

Cloud solutions

28- What is the difference Delegates and Callbacks?

The difference between delegates and callbacks is that with delegates, the NetworkService is telling the delegate “There is something changed.” With callbacks, the delegate is observing the NetworkService.

Check this out.

29- Explain Linked List

Linked List basically consist of the structures we named the Node. These nodes basically have two things. The first one is the one we want to keep. (we do not have to hold single data, we can keep as much information as we want), and the other is the address information of the other node.

Disadvantages of Linked Lists, at the beginning, there is extra space usage. Because the Linked List have an address information in addition to the existing information. This means more space usage.

30- Do you know Back End development ?

Depends. I have experienced PARSE and I am awarded FBStart. I decided to learn pure back end. You have two choices. Either you can learn node.js + express.js and mongodb. OR, you can learn Vapor or Kitura.

Don’t you like or use Firebase?

Firebase doesn't have a path for macOS X developers.

If you want to learn Firebase, please just follow one month of Firebase Google Group.

31- Explain AutoLayout

AutoLayout provides a flexible and powerful layout system that describes how views and the UI controls calculates the size and position in the hierarchy.

32- What is the disadvantage to hard-coding log statements ?

First, when you start to log. This starts to accumulate. It may not seem like a lot, but every minute adds up. By the end of a project, those stray minutes will equal to hours.

Second, Each time we add one to the code base, we take a risk of injecting new bugs into our code.

33- What is Pointer ?

A pointer is a direct reference to a memory address. Whereas a variable acts as a transparent container for a value, pointers remove a layer of abstraction and let you see how that value is stored.

34- Explain Core ML Pros and Cons

Pros of Core ML:

  • Really easy to add into your app.
  • Not just for deep learning: also does logistic regression, decision trees, and other “classic” machine learning models.
  • Comes with a handy converter tool that supports several different training packages (Keras, Caffe, scikit-learn, and others).


  • Core ML only supports a limited number of model types. If you trained a model that does something Core ML does not support, then you cannot use Core ML.
  • The conversion tools currently support only a few training packages. A notable omission is TensorFlow, arguably the most popular machine learning tool out there. You can write your own converters, but this isn’t a job for a novice. (The reason TensorFlow is not supported is that it is a low-level package for making general computational graphs, while Core ML works at a much higher level of abstraction.)
  • No flexibility, little control. The Core ML API is very basic, it only lets you load a model and run it. There is no way to add custom code to your models.
  • iOS 11 and later only.

For more information.

35- What is pair programming?

Pair programming is a tool to share information with junior developers. Junior and senior developer sitting side-by-side this is the best way for the junior to learn from senior developers.

Check out Martin Fowler on “Pair Programming Misconceptions”, WikiHow on Pair Programming

36- Explain blocks

Blocks are a way of defining a single task or unit of behavior without having to write an entire Objective-C class. they are anonymous functions.

37- What is Keychain ?

Keychain is an API for persisting data securly in iOS App. It is secured using a hardware module and is backed up to iCloud. I highly recomend a good library - Locksmith

38- What is the biggest changes in UserNotifications ?

  • We can add audio, video and images.
  • We can create custom interfaces for notifications.
  • We can manage notifications with interfaces in the notification center.
  • New Notification extensions allow us to manage remote notification payloads before they’re delivered.

39- Explain the difference between atomic and nonatomic synthesized properties

atomic : It is the default behaviour. If an object is declared as atomic then it becomes thread-safe. Thread-safe means, at a time only one thread of a particular instance of that class can have the control over that object.

nonatomic: It is not thread-safe. We can use the nonatomic property attribute to specify that synthesized accessors simply set or return a value directly, with no guarantees about what happens if that same value is accessed simultaneously from different threads. For this reason, it’s faster to access a nonatomic property than an atomic one.

40- Why do we use availability attributes ?

Apple wants to support one system version back, meaning that we should support iOS9 or iOS8. Availability Attributes lets us to support previous version iOS.

41- How could we get device token ?

There are two steps to get device token. First, we must show the user’s permission screen, after we can register for remote notifications. If these steps go well, the system will provide device token. If we uninstall or reinstall the app, the device token would change.

42- What is Encapsulation ?

Encapsulation is an object-oriented design principles and hides the internal states and functionality of objects. That means objects keep their state information private.

43- What is big-o notation ?

An algorithm is an impression method used to determine the working time for an input N size. The big-o notation grade is expressed by the highest value. And the big-o notation is finding the answer with the question of O(n). Here is a cheat sheet and swift algorithm club. For example;

For Loops big-o notation is O(N). Because For Loops work n times.

Variables (var number:Int = 4) big-o notation is O(1).

44- What Is Dependency Management?

If we want to integrate open source project, add a framework from a third party project, or even reuse code across our own projects, dependency management helps us to manage these relationships. Check this out

45- What is UML Class Diagrams?

UML Class Diagram is a set of rules and notations for the specification of a software system, managed and created by the Object Management Group.

46- Explain throw

We are telling the compiler that it can throw errors by using the throws keyword. Before we can throw an error, we need to make a list of all the possible errors you want to throw.

47- What is Protocol Extensions?

We can adopt protocols using extensions as well as on the original type declaration. This allows you to add protocols to types you don’t necessarily own.

48- What is three triggers for a local notification ?

Location, Calendar, and Time Interval. A Location notification fires when the GPS on your phone is at a location or geographic region. Calendar trigger is based on calendar data broken into date components. Time Interval is a count of seconds until the timer goes off.

49- Explain Selectors in ObjC

Selectors are Objective-C’s internal representation of a method name.

50- What is Remote Notifications attacment’s limits ?

We can be sent with video or image with push notification. But maximum payload is 4kb. If we want to sent high quality attachment, we should use Notification Service Extension.

My recommendations

  • A curated awesome list of iOS interview questions.

That’s it. 😃😃😃 Thanks for reading. I hope all these questions will help you in your interviews. Part 4 is ready.

If you want to follow me in social media, here are some links. github, twitter, instagram

You can check my previous article here.

Written by

Health Research Program’s iOS Developer, currently lives in Washington, D.C http://www.about.me/durul

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store