Last active
August 29, 2015 14:17
-
-
Save ahmetws/15b319b49861ee8c15e4 to your computer and use it in GitHub Desktop.
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
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