title: how manipulate a NSDictionary generated by a json file in swift
body: <p>I've a NSDictionary populated by a JSON file.
  JSON file content (initially)</p>
  
  <pre><code>{
  "length" : 0, 
  "locations" : []
  }
  </code></pre>
  
  <p>I want add some elements in "locations". The elements have the below structure:</p>
  
  <pre><code>[
  "name" : "some_name", 
  "lat" : "4.88889", 
  "long" : "5.456789", 
  "date" : "19/01/2015"
  ]
  </code></pre>
  
  <p>In next code I read de JSON File</p>
  
  <pre><code>let contentFile = NSData(contentsOfFile: pathToTheFile)
  let jsonDict = NSJSONSerialization.JSONObjectWithData(contentFile!, options: nil, error: &amp;writeError) as NSDictionary`
  </code></pre>
  
  <p>like you can see <code>jsonDict</code> contain the JSON's info but in a NSDictionary object.</p>
  
  <p>At this point I can't add the elements mentioned before, I tried insert NSData, NSArray, Strings, and nothing results for me</p>
  
  <p>After do this I want convert "final" NSDictionary in JSON again to save it in a file.</p>
  
  <p>The "final" NSDictionary must be like this</p>
  
  <pre><code>{
  "length" : 3, 
  "locations" : [
      {
      "name" : "some_name", 
      "lat" : "4.88889", 
      "long" : "5.456789", 
      "date" : "19/01/2015"
      },
      {
      "name" : "some_name_2", 
      "lat" : "8.88889", 
      "long" : "9.456789", 
      "date" : "19/01/2015"
      },
      {
      "name" : "some_name_3", 
      "lat" : "67.88889", 
      "long" : "5.456789", 
      "date" : "19/01/2015"
      }
  ]
  }
  </code></pre>
  
  <p>"length" control the  index for new element</p>
  
  <p>I have no more ideas to do this. thanks in advance</p>