title: how to call Swift closure callback
body: <p>I am trying to get service data in presenter and then invoking method from presenter using view reference in ViewController
  ho can i get callback from service.
  i have Service/Presenter/View
  My Code is as follows</p>
  
  <p>ViewController</p>
  
  <pre><code>class ViewController: UIViewController, UserView {
  
      private var userPresenter: UserPresenter?
  
      override func viewDidLoad() {
          super.viewDidLoad()
          userPresenter = UserPresenter(userView: self)
          userPresenter?.getUsers()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      func startLoading() {
          print("Start loading is called")
      }
  
      func stopLoading() {
          print("Stop loading is called")
      }
  
      func onEmpty() {
          print("Empty users returned")
      }
  
      func onUsers(users: [User]) {
          for userItem in users {
              print("User name \(userItem.getName())")
          }
      }
  
  }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>protocol UserView: NSObjectProtocol {
      func startLoading()
  
      func stopLoading()
  
      func onUsers(users: [User])
  
      func onEmpty()
  }
  </code></pre>
  
  <p>Service</p>
  
  <pre><code>public class UserService {
  
      func getUsers(delay: Double, completion: @escaping ([User]) -&gt; Void) {
          var users = [User]()
  
  
          users.append(User(name: "User 1", email:"user1@gmail.com", age: 25))
          users.append(User(name: "User 2", email: "user2@gmail.com", age: 26))
          users.append(User(name: "User 3", email: "user3@gmail.com", age: 27))
  
          DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
              print("Sending users")
              completion(users)
              print("Sent user")
          }
      }
  }
  </code></pre>
  
  <p>Presenter</p>
  
  <pre><code>class UserPresenter {
  
      private var userService: UserService
      weak private var userView: UserView?
  
      init(userView: UserView) {
          self.userView = userView
          userService = UserService()
      }
  
      func detachView() {
          self.userView = nil
      }
  
      func getUsers() {
          self.userView?.startLoading()
          userService.getUsers(delay: 5000, completion: {
              users: [User] -&gt; Void
                  print("adad")
          })
  
  }
  </code></pre>
  
  <p>How should i get the callback method when async task finishes</p>
  
  <pre><code>func getUsers() {
      self.userView?.startLoading()
  
      userService.getUsers(delay: 5000){ users in
  
          print("\(users.count) users added")
  
          //            self.userView?.onUsers(users: users)
          //            self.userView?.stopLoading()
  
      }
  }
  </code></pre>
  
  <p>This is not working as given in answer by @vadian</p>