title: How to post Image to Twitter with Rest API in Swift?
body: <p>In my app the user should upload a picture to Twitter (with the Rest API).
  Now the user can only tweet with text but this works with this code:</p>
  
  <pre><code>let textToTweet = textView.text
  
      let url = NSURL(string: "https://api.twitter.com/1.1/statuses/update.json")
  
      let request = SLRequest(forServiceType: SLServiceTypeTwitter, requestMethod: .POST, URL: url, parameters: ["status": textToTweet!])
      request.account = twitterAccount
      request.performRequestWithHandler { (data, response, error) -&gt; Void in
  
          if response.statusCode != 200 {
  
              print("not working")
  
          }
      }
  </code></pre>
  
  <p>Now I wanted to take a step forward and used this, but it´s not working with this code. :</p>
  
  <pre><code> let textToTweet = textView.text
      let imageToTweet = image.image
  
      let url = NSURL(string: "https://api.twitter.com/1.1/statuses/update_with_media.json")
  
      let request = SLRequest(forServiceType: SLServiceTypeTwitter, requestMethod: .POST, URL: url, parameters: ["status": textToTweet!, "media[]": imageToTweet!])
  
      request.account = twitterAccount
      request.performRequestWithHandler { (data, response, error) -&gt; Void in
  
          if response.statusCode != 200 {
  
              print(error)
  
          }
      }
  </code></pre>
  
  <p>Here´s the information that gives Twitter about <a href="https://dev.twitter.com/rest/reference/post/statuses/update_with_media" rel="nofollow">POST statuses/update_with_media</a>. The console is showing "fatal error: unexpectedly found nil while unwrapping an Optional value" and the app isn´t posting the post or the image.
  Thank you!</p>