Skip to content

Instantly share code, notes, and snippets.

@jmahmood
Created June 3, 2014 13:45
Show Gist options
  • Save jmahmood/f436a6ce293ba25f91c5 to your computer and use it in GitHub Desktop.
Save jmahmood/f436a6ce293ba25f91c5 to your computer and use it in GitHub Desktop.
import Cocoa
// Load data from a URL.
let url: NSURL = NSURL(string: "http://www.tokyomuslim.com")
let resultsData = NSData(contentsOfURL: url, options: NSDataReadingOptions.DataReadingUncached, error: nil)
let resultsString:NSString = NSString(data: resultsData, encoding: NSUTF8StringEncoding)
// Load JSON data.
let jsonUrl: NSURL = NSURL(string: "https://api.github.com/users/mralexgray/repos/")
let jsonResultsData = NSData(contentsOfURL: jsonUrl, options: NSDataReadingOptions.DataReadingUncached, error: nil)
let jsonResultsString:NSString = NSString(data: jsonResultsData, encoding: NSUTF8StringEncoding)
var jsonResultsDict:NSArray = NSJSONSerialization.JSONObjectWithData(jsonResultsData, options: nil, error: nil) as NSArray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment