{"action":"created","issue":{"url":"https://api.github.com/repos/y-vm/y-vm.github.io/issues/1","repository_url":"https://api.github.com/repos/y-vm/y-vm.github.io","labels_url":"https://api.github.com/repos/y-vm/y-vm.github.io/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/y-vm/y-vm.github.io/issues/1/comments","events_url":"https://api.github.com/repos/y-vm/y-vm.github.io/issues/1/events","html_url":"https://github.com/y-vm/y-vm.github.io/issues/1","id":99153261,"number":1,"title":"iOS","user":{"login":"2892","id":4101720,"avatar_url":"https://avatars.githubusercontent.com/u/4101720?v=3","gravatar_id":"","url":"https://api.github.com/users/2892","html_url":"https://github.com/2892","followers_url":"https://api.github.com/users/2892/followers","following_url":"https://api.github.com/users/2892/following{/other_user}","gists_url":"https://api.github.com/users/2892/gists{/gist_id}","starred_url":"https://api.github.com/users/2892/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2892/subscriptions","organizations_url":"https://api.github.com/users/2892/orgs","repos_url":"https://api.github.com/users/2892/repos","events_url":"https://api.github.com/users/2892/events{/privacy}","received_events_url":"https://api.github.com/users/2892/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/y-vm/y-vm.github.io/labels/iOS","name":"iOS","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":64,"created_at":"2015-08-05T08:41:15Z","updated_at":"2016-03-13T07:58:28Z","closed_at":null,"body":"Learn Cocoa.\r\n\r\n- Cocoa\r\n- Cocoa Touch\r\n\r\n```\r\nclass ViewController: UIViewController, UITableViewDataSource {\r\n    @IBOutlet weak var indexTableView: UITableView!\r\n    @IBOutlet weak var indexIndicator: UIActivityIndicatorView!\r\n    \r\n    let urlOfAPIs = NSURL(string: \"https://api.douban.com/v2/movie/top250?apikey=\")\r\n    let sharedSession = NSURLSession.sharedSession()\r\n    \r\n    var dataSubjects : NSArray = []\r\n    var dataCount : Int = 0\r\n    \r\n    func numberOfSectionsInTableView(tableView: UITableView) -> Int {\r\n        return 1\r\n    }\r\n    \r\n    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\r\n        return dataCount\r\n    }\r\n    \r\n    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {\r\n        let tableViewCell = tableView.dequeueReusableCellWithIdentifier(\"indexCell\", forIndexPath: indexPath) as UITableViewCell\r\n        \r\n        tableViewCell.textLabel!.text = dataSubjects[indexPath.row][\"title\"] as? String\r\n        tableViewCell.detailTextLabel?.text = dataSubjects[indexPath.row][\"year\"] as? String\r\n        \r\n        let dataImages = dataSubjects[indexPath.row][\"images\"]!\r\n        let dataImageUrl = dataImages![\"small\"] as? String\r\n        \r\n        if let imageUrl = NSURL(string: dataImageUrl!) {\r\n            if let imageData = NSData(contentsOfURL: imageUrl) {\r\n                tableViewCell.imageView?.image = UIImage(data: imageData)\r\n            }\r\n        }\r\n        \r\n        return tableViewCell\r\n    }\r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        \r\n        indexTableView.hidden = true\r\n        indexIndicator.startAnimating()\r\n        \r\n        let downloadTask : NSURLSessionDownloadTask = sharedSession.downloadTaskWithURL(urlOfAPIs!) { (location: NSURL?, response: NSURLResponse?, error: NSError?) -> Void in\r\n            let contentsOfUrl = NSData(contentsOfURL: location!)\r\n            \r\n            do {\r\n                let contentsAsDictionary : NSDictionary? = try NSJSONSerialization.JSONObjectWithData(contentsOfUrl!, options: []) as? NSDictionary\r\n                if let contentsOfJSON = contentsAsDictionary {\r\n                    print(contentsOfJSON[\"title\"])\r\n                    \r\n                    self.dataCount = contentsOfJSON[\"count\"] as! Int\r\n                    self.dataSubjects = contentsOfJSON[\"subjects\"] as! NSArray\r\n                }\r\n                \r\n                dispatch_async(dispatch_get_main_queue(), { () -> Void in\r\n                    self.indexTableView.reloadData()\r\n                    self.indexTableView.hidden = false\r\n                    self.indexIndicator.stopAnimating()\r\n                })\r\n            }\r\n            catch let error as NSError {\r\n                print(error)\r\n            }\r\n        }\r\n        \r\n        downloadTask.resume()\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/y-vm/y-vm.github.io/issues/comments/195910550","html_url":"https://github.com/y-vm/y-vm.github.io/issues/1#issuecomment-195910550","issue_url":"https://api.github.com/repos/y-vm/y-vm.github.io/issues/1","id":195910550,"user":{"login":"2892","id":4101720,"avatar_url":"https://avatars.githubusercontent.com/u/4101720?v=3","gravatar_id":"","url":"https://api.github.com/users/2892","html_url":"https://github.com/2892","followers_url":"https://api.github.com/users/2892/followers","following_url":"https://api.github.com/users/2892/following{/other_user}","gists_url":"https://api.github.com/users/2892/gists{/gist_id}","starred_url":"https://api.github.com/users/2892/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2892/subscriptions","organizations_url":"https://api.github.com/users/2892/orgs","repos_url":"https://api.github.com/users/2892/repos","events_url":"https://api.github.com/users/2892/events{/privacy}","received_events_url":"https://api.github.com/users/2892/received_events","type":"User","site_admin":false},"created_at":"2016-03-13T07:58:28Z","updated_at":"2016-03-13T07:58:28Z","body":"```swift\r\nabs(-1)\r\nmax(-1, 0, 1)\r\n```"}}