title: How to use swift-4 Promises then, done, catch and other blocks
body: <p>I would like to learn about promises in swift-4. How to use multiple then statements and done, catch blocks.</p>
  
  <p>Here I am trying to get the value from the promise. But I'm getting errors. Could someone help me to understand promises? </p>
  
  <p>Here is my code. </p>
  
  <pre><code>import UIKit
  import PromiseKit
  
  struct User {
      var firstname : String?
      var lastname  : String?
  }
  
  struct APIError {
      var message : String?
  }
  
  class ViewController : UIViewController {
      override func viewDidLoad() {
          super.viewDidLoad()
          let userPromise : Promise = self.getUserDetails()
          userPromise.then { user -&gt; Void in
              //print(user.f)
          }
      }
  
      func getUserDetails()-&gt;Promise&lt;User&gt; {
          return Promise&lt;User&gt; { resolve in
              let user  = User(firstname: "Scot", lastname: "dem")
              if ((user.firstname?.count) != nil) {
                  resolve.fulfill(user)
              } else {
                  let error = APIError(message: "User not valid")
                  resolve.reject(error as! Error)
              }
          }
      }
  }
  </code></pre>
  
  <p>Once I get the user details I want to make a full name, uppercase promises which are dependent on userPromise.  </p>
  
  <p>I would like to use multiple then, done, finally blocks. Just want to understand usage.</p>
  
  <blockquote>
    <p>Why I'm getting an error here when we use userPromise.then { user -> Void in</p>
  </blockquote>
  
  <p>what should I give inside the block</p>