Skip to content

Instantly share code, notes, and snippets.

@ahmetws
Last active August 29, 2015 14:17
Show Gist options
  • Save ahmetws/15b319b49861ee8c15e4 to your computer and use it in GitHub Desktop.
Save ahmetws/15b319b49861ee8c15e4 to your computer and use it in GitHub Desktop.
func getTwitterData() {
let urlString = "http://***.com/twitter.php?tag=mef"
let request = NSURLRequest(URL: NSURL(string:urlString)!)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) { (response, data, error) -> Void in
let json = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.allZeros, error: nil) as [String:AnyObject]
println(json)
self.textLabel.text = "Twitler Geldi"
self.textList = json["statuses"] as [AnyObject]
}
}
@IBAction func changeItTapped(sender: UIButton) {
if textList.count < 0 {
return
}
let diceRoll = Int(arc4random_uniform(UInt32(textList.count)))
let twit: AnyObject = textList[diceRoll]
textLabel.text = twit["text"] as? String
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment