Ios developer Interview Questions | Glassdoor.co.uk

# Ios developer Interview Questions

126

ios developer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

17 Dec 2017
 Giving an array of numbers and an int, return true if is there any pair of numbers inside the array that summed is equal to the input int, otherwise return false.5 Answers-(void)findPair{ NSArray *array = @[@0,@4,@3,@3,@5,@1,@8,@2,@6]; int sum ; int input = 7; for(int i=0;i<[array count];i++) { for(int j=0;j!=i && j<[array count];j++) { { sum = [[array objectAtIndex:i] intValue] + [[array objectAtIndex:j] intValue]; if(sum == input) { NSLog(@"Pair found and values are %d and %d",[[array objectAtIndex:i] intValue],[[array objectAtIndex:j]intValue]); } } } } }The above solution would be very slow. I suggest not square looping through the array because in case there is no pair your algorithm would have to loop it array.count^2 times. For example, if we have an array of 100 numbers and none of them builds up a pair you would have to iterate 10000 times. I would suggest looping the array just once but at every iteration to save a value by a key of its complement to the local dictionary and just check every time if there is a value by a key of the current number. In Swift it would look like this: func hasPair(array: [Int], input: Int) -> Bool { var complementDict = [Int : Int]() for int in array { if int <= input { if let complement = complementDict[int] { print("\(complement) + \(int) = \(input)") return true } let complement = input - int complementDict[complement] = int } } print("Did not found any pair") return false } And this is Obj-C version: -(BOOL)hasPairIn:(NSArray*)array for:(NSNumber*)input { NSMutableDictionary* complementDict = [NSMutableDictionary new]; for (NSNumber* num in array) { if (num <= input) { if (complementDict[num] != nil) { NSLog(@"%@ + %@ = %@", complementDict[num], num, input); return YES; } NSNumber* complement = [NSNumber numberWithInt:[input intValue] - [num intValue]]; complementDict[complement] = num; } } NSLog(@"Did not found any pair"); return NO; }let arr = [0, 8, 15, 77, 88, 9] func hasTwoNumbersThatSum(to:Int, arr:[Int]) -> Bool { let numberSet = Set(arr) for num in numberSet { let otherNum = to - num if numberSet.contains(otherNum){ return true } } return false } print(hasTwoNumbersThatSum(to: 25, arr: arr))Show more responsesOne problem with both of the above is that if you had a array such as [5, 0, 6] and your number was 10, it would evaluate to true, as the compliment of 5 is in the array (but only once).let array = [7,9,3,5,6] var minIndex:Int = 0 var maxIndex:Int = array.count - 1 var middleIndex:Int { Int(maxIndex - minIndex / 2) } let min = array.first while minIndex = array[middleIndex] { //right side minIndex = middleIndex + 1 } else if array[minIndex] <= array[middleIndex] { //left side maxIndex = middleIndex - 1 } } print(array[middleIndex])

17 Dec 2017
 How would you implement UIView hitTest mehtod?3 AnswersThanks for sharing your experience and much appreciated. It would be really great if could post remaining questions as well to help others to fulfil their dream job.UIView * hitTest(UIView *view, CGPoint point, UIEvent *event) { if (view == nil) return nil; if (CGRectContainsPoint(view.bounds, point)) return view; else hitTest(view.superView, point, event); }UIView * hitTest(UIView *view, CGPoint point, UIEvent *event) { if (CGRectContainsPoint(view.bounds, point); return view; for (UIView *view in view.subViews) { hitTest(view, point, event); } }

17 Dec 2017
 Giving a circular sorted array Ex: [7,9,3,5,6], write an algorithm that finds the smaller element index. 3 Answersint findMinElement(int arr[], int size) { int low = 0; int high = size - 1; while (low <= high) { int middle = (low + high)/2; if ((arr[middle] < arr[middle - 1]) && (arr[middle] < arr[middle + 1])) { return arr[middle]; } else if (arr[middle] < arr[size - 1]) { high = middle - 1; } else { low = middle + 1; } } return -1; }func isOn(_ array: [Int],_ num: Int) -> Bool { var dictionary = [Int:Bool]() for curr in array { let currResult = num - curr if dictionary[currResult] == nil { dictionary[currResult] = true } else { return true } } return false } let arr = [1,1,4,12] let num = 2 print("isOn=\(isOn(arr, num))") One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

### IOS Developer at Farmdrop was asked...

15 Jun 2018
 Why do you think what Farmdrop is doing is important1 AnswerCovered off the sustainability aspects of the food grown by suppliers. I had read the book Farmageddon: The True Cost of Cheap Meat to appreciate the goal of the company

### IOS Developer at FATUnicorn was asked...

23 Mar 2016
 Implement three different tasks in Swift: - An app to take pictures with the front camera - An app which moves textfields when keyboard appears - Another app which uses CoreData and updates a list from an endpoint1 AnswerI've got experience in iOS and it was easy to implement.

### IOS Developer at The App Experts (UK) was asked...

20 Sep 2019
 Q: What is Polymorphism?1 AnswerA: Its the ability of one object representing several types at a time, or a function which implementation varies on the passed in argument's type.

### IOS Developer at The App Experts (UK) was asked...

20 Sep 2019
 Q: What are the Pillars of Object Oriented Programming?1 AnswerA: Encapsulation, Polymorphism, Inheritance, Abstraction.

### IOS Developer at Monzo Bank was asked...

23 Apr 2020
 Standard questions and silly and boring tech questions around app architecture. MVVM, MVC, VIPER, etc 1 AnswerCan't remember

### IOS Developer at IG was asked...

26 Jul 2016
 Implement sliding programme grid app for iOS. Technical requirements were given, along with REST API of BBC 4 channel.1 AnswerImplemented everything to the spec, including unit testing (even negative cases).

25 Mar 2018