Skip to content

Instantly share code, notes, and snippets.

@castillejoale
Created January 20, 2017 03:20
Show Gist options
  • Save castillejoale/659b70fba2ee52857653042a2d676a51 to your computer and use it in GitHub Desktop.
Save castillejoale/659b70fba2ee52857653042a2d676a51 to your computer and use it in GitHub Desktop.
import UIKit
import AVFoundation
//Dictionary -> JSON String
let dictionary = ["aKey": "aValue", "anotherKey": "anotherValue"]
var theJSONText:String?
do {
let theJSONData = try NSJSONSerialization.dataWithJSONObject(dictionary , options: NSJSONWritingOptions(rawValue: 0))
theJSONText = String(data: theJSONData,
encoding: NSASCIIStringEncoding)
} catch let error as NSError {
print(error.localizedDescription)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment