Curated iOS Interview Questions Series — Part 2
Series aiming to cover as many Q&A’s as possible from iOS interview perspective.
Do check out Part-1 before proceeding further.
Q26. Higher order functions in swift?
Higher order functions are functions that takes another function/closure as argument and returns it
Q27. Create your own Filter function in swift?
Q28. Swift object life cycle?
Q29. weak vs unowned in swift?
Weak references are always optional and automatically becomes nil when referenced object goes away.
Unowned object are never optional types, If you try to access unowned property that refers to de-initialized object, it will lead to runtime error similar to force unwrap nil optional type.
Q30. Example of swift object getting deallocated after end of scope.
Q31. What would be the output in Swift Playground?
Output: Empty String, instance of anotherObject would be immediately deallocated because it is marked as weak.
Q32. What would be the output in Swift Playground?
Q33. What would be the output in Swift Playground?
Output: 3 1 2 as main queue is sequential
Q34. What would be the output in Swift Playground?
Output: a b c r w s m then runtime error before executing print(“p”)
Follow me Rahul Goel for further updates.