title: SWIFT: Parsing a JSON Object
body: <p>first post here!</p>
  
  <p>I've been working on my own weather application (I'm a high school student who's self-learning Swift, but already have experience in Java). </p>
  
  <p>I'm learning how to use API's to gather information to use in my application and I've been using this video: <a href="https://www.youtube.com/watch?v=r-LZs0De7_U" rel="nofollow">https://www.youtube.com/watch?v=r-LZs0De7_U</a></p>
  
  <p>At around the 11:38 mark, a JSON object is created:</p>
  
  <pre><code>    var jsonError: NSError
      let json = NSJSONSerialization.JSONObjectWithData(weatherData, options: nil, error: &amp;jsonError) as NSDictionary
  
      if let name = json["name"] as? String {
          cityNameLabel.text = name
      }
  
      if let main = json["main"] as? NSDictionary {
          if let temp = main["temp"] as? Double {
              cityTemperatureLabel.text = String(format: "%.1f", arguments: temp)
          }
  </code></pre>
  
  <p>Basically I want to parse a String out of the JSON object and have my UILabel store the String. </p>
  
  <p>However, the second line of code gives me an error saying: 'NSError is not identical to NSError?' and I couldn't find a solution to this error, so I got rid of the first two lines and replaced them with: </p>
  
  <pre><code>    var jsonError : NSError?
  
      let json: AnyObject? = NSJSONSerialization.JSONObjectWithData(weatherData, options: nil, error: &amp;jsonError)
  
  
      if let error = jsonError{
          println("error occurred: \(error.localizedDescription)")
      }
      else if let jsonDict = json as? NSDictionary{
          println("json is dictionary \(jsonDict)")
      }
      else if let jsonArray = json as? NSArray{
          println("json is an array: \(jsonArray)")
      }
  </code></pre>
  
  <p>This got rid of the error but the rest of the code didn't work anymore. Any possible solutions + explanations? I am still new to API's/JSON so apologies if I am not explaining my problem well. 
  The video should be able to help you guys help me!</p>
  
  <p>EDIT: Apparently I am using Swift version 1.2</p>