JOBSEEKER?

iOS and Swift Interview Questions

Practice for iOS and Swift interviews by solving TestDome questions. Our interview questions are used by more than 7,000 companies and 450,000 individual test takers.

Jobseekers: Certify Your Knowledge

Take a Certification Test

Companies: Use Our Tests for Screening

Buy a Pack Of Candidates

Need to practice your iOS and Swift skills for an upcoming job interview? Try solving these iOS interview questions that test knowledge of iOS APIs, the Swift programming language, and mobile development concepts. We’ll provide feedback on your answers, and you can use a hint if you get stuck.

These iOS interview questions are examples of real tasks used by employers to screen job candidates for mobile development jobs that require knowledge of the iOS environment in order to create and maintain iOS applications.

1. UITableView

UI
   
Easy  

Select the components that are minimally required for constructing and configuring a UITableViewController, which can be used to view (but not manipulate) a list of items.

(Select all acceptable answers.)

UITableViewSource
UITableViewCell
UITableViewDelegate
UITableViewDataSource
UIViewController
   


2. View Controller

Event handling UI
   
Easy  

Which of the following statements are true for UIViewController?

(Select all acceptable answers.)

viewWillAppear will be called before a view appears on the screen.
viewDidRender will be called after a view renders on the screen.
viewWillDisappear is called after animations are configured.
When using storyboards, the controller is initialized with the init(coder:)/initWithCoder method.
View controllers manage a hierarchy of views.
   


3. Car

Swift
   
Easy  

Consider the following Swift definition of the structure Car:

struct Car {
    var color:UIColor?
    let model:String
    
    init(model:String) {
        self.model = model
        self.color = nil
    }

    mutating func changeColor(color:UIColor) {
        self.color = color
    }
}

Select the statements that are correct.

(Select all acceptable answers.)

The struct Car can be inherited from to create child structs.
The initializer init is required to set the initial values of all properties.
The property model cannot be changed after initialization.
The mutating keyword of changeColor is required to modify the instance variable color.
The changeColor function can set the property color to nil.
   


4. Events

Event handling
   
Easy  

Which of the following statements are true for user interface events in iOS?

(Select all acceptable answers.)

Touch up inside is an event provided by UIControl.
Drag and drop is a UIControl event.
Touch events can be cancelled.
Remote control events can be cancelled.
The first responder to an event can be changed.
The fast swipe event is provided by iOS.
Capturing swipe events is supported through a gesture recognizer.
   


5. User Subscription

Memory management Swift
   
Easy 

An application uses the User and Subscription classes for tracking all subscriptions that a user has purchased. Currently, the memory occupied by instances of those classes is never reclaimed.

Without changing the public API, fix the memory leak.

Swift 5.2  
 


  •   Memory is reclaimed: Memory limit exceeded


6. Two Sum

Algorithmic thinking Dictionary Swift
   
Easy 

Write a function that when passed an array and a target sum, returns, efficiently with respect to time used, two distinct zero-based indices of any two of the numbers whose sum is equal to the target sum. If there are no two numbers, the function should return nil.

For example, findTwoSum([ 3, 1, 5, 7, 5, 9 ], 10) should return a single dimensional array with two elements and contain any of the following pairs of indices:

  • 0 and 3 (or 3 and 0) as 3 + 7 = 10
  • 1 and 5 (or 5 and 1) as 1 + 9 = 10
  • 2 and 4 (or 4 and 2) as 5 + 5 = 10
Swift 5.2  
 


  •   Example case: Wrong answer
  •   Distinct numbers with and without solutions: Wrong answer
  •   Duplicate numbers with and without solutions: Wrong answer
  •   Performance test with a large list of numbers: Wrong answer


7. Readable Object

OOP Protocols Swift
   
Hard 

Change the Readable protocol and the ReadableObject and EmptyReadableObject classes so that:

  • ReadableObject and EmptyReadableObject implement the Readable protocol.
  • When the read method is called on the ReadableObject class, it returns the value that it received in the constructor.
  • The isReadable method returns true in the ReadableObject classand returns false in the EmptyReadableObject class.
Swift 5.2  
 


  •   ReadableObject and EmptyReadableObject implement the Readable protocol: Wrong answer
  •   When the read method is called on the ReadableObject class, it returns the value that it received in the constructor: Wrong answer
  •   The isReadable method returns true in the ReadableObject class, and returns false in the EmptyReadableObject class: Exception


If you feel ready, take one of our timed public iOS and Swift Interview Questions tests:
iOS and Swift

iOS Online Test (Easy)

iOS and Swift Online Test (Easy)

Not exactly what you are looking for? Go to our For Jobseekers section.
Dashboard Start Trial Sign In Home Tour Tests Questions Pricing For Jobseekers