Skip to content

Instantly share code, notes, and snippets.

@mc256
Created October 3, 2015 19:50
Show Gist options
  • Save mc256/bfcc08f6e0fe67c4b21b to your computer and use it in GitHub Desktop.
Save mc256/bfcc08f6e0fe67c4b21b to your computer and use it in GitHub Desktop.
mediawiki api swift handler
let pageRawData:NSData = try NSData(contentsOfURL: targetURL, options: [])
var tempData:NSDictionary = try NSJSONSerialization.JSONObjectWithData(pageRawData, options:.MutableContainers ) as! NSDictionary
tempData = tempData.objectForKey("query")!.objectForKey("pages") as! NSDictionary
tempData = tempData.objectForKey(tempData.keyEnumerator().nextObject()!) as! NSDictionary
let content = tempData.objectForKey("revisions")?.objectAtIndex(0).objectForKey("*") as! String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment