-
-
Save ericcgu/919baeed56b3519a803b to your computer and use it in GitHub Desktop.
JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SYCRONOUS | |
var currencyList = Dictionary<String, String>() | |
currencyList = ["EUR":"European Euro" , | |
"GPB":"British Pounds", | |
"USD":"US Dollar", | |
"JPY":"Japanese Yen", | |
"RMB":"Chinese Renminbi", | |
"HKD":"Hong Kong Dollar", | |
"CAD":"Canadian Dollar", | |
"MXN":"Mexican Peso", | |
"CHF":"Swiss Franc", | |
"IND":"Indian Rupee" | |
] | |
let query="JPY_HKD" | |
let baseURL = NSURL(string: "http://www.freecurrencyconverterapi.com/api/v2/") | |
let forecastURL = NSURL(string: "convert?q="+query, relativeToURL: baseURL) | |
//use a session object to manage.//like the sun | |
let sharedSession = NSURLSession.sharedSession() | |
var error: NSError? | |
let url: NSURL = NSURL.URLWithString("http://sophisticatedignorance.net/api/get_recent_summary/") | |
let data = NSData.dataWithContentsOfURL(url, options:.DataReadingMappedIfSafe , error: nil) | |
/* get your json data */ | |
let jsonDict = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: &error) as NSDictionary | |
println(jsonDict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment