InterviewSolution
Saved Bookmarks
| 1. |
Suppose you are developing an application that lists news updates for a nearby location. Like popular apps on the store, the client also wants to do it using a paginating mechanism. How would you implement this? |
|
Answer» Dependency injection is a technique/pattern help to adopt loose COUPLING between related OBJECTS. It also helps in unit testing. The above EXAMPLE demonstrates one of the types of Dependency Injection, property INJECTIONS. Here we are injecting Network manager instance when it required. class LogInViewController: UIViewController { var networkManager : NetworkManager? } func loginAction(){ LET loginVC = myStoryboard.instantiateViewController(withIdentifier: "LogInViewController") as! LogInViewController loginVC.networkManager = NetworkManager() loginVC.networkManager.doSomeAction() } |
|