{"action":"created","comment":{"url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/comments/74339878","id":74339878,"diff_hunk":"@@ -0,0 +1,174 @@\n+//\n+//  ConverterViewController.swift\n+//  anarmyofones\n+//\n+//  Created by Fabian Mariño on 4/4/16.\n+//  Copyright © 2016 Fabian Mariño. All rights reserved.\n+//\n+\n+import UIKit\n+\n+// MARK: Local Constants\n+\n+// Define server side script URL\n+let EXCHANGESURL = \"https://api.fixer.io/latest?base=USD&symbols=GBP,EUR,JPY,BRL\"\n+let REQUESTMETHOD = \"GET\"\n+let CURRENCIES = [ \"UK\": \"GBP\",\n+                   \"EUR\": \"EUR\",\n+                   \"JAP\": \"JPY\",\n+                   \"BRA\": \"BRL\"\n+                 ]\n+let FIELDMAXLENGTH = 8\n+let DEFAULTAMOUNT = 1.0\n+\n+class ConverterViewController: UIViewController, UITextFieldDelegate {\n+    \n+    var _dollarAmount: Double? = DEFAULTAMOUNT\n+    var _exchangesDictionary:[String:Double]?\n+    let _currencyFormatter : NSNumberFormatter = NSNumberFormatter()\n+    var _requestedWasOk = false\n+    \n+    @IBOutlet weak var lblGBP: UILabel!\n+    @IBOutlet weak var lblEUR: UILabel!\n+    @IBOutlet weak var lblBRL: UILabel!\n+    @IBOutlet weak var lblJPY: UILabel!\n+    \n+    @IBOutlet weak var dollarNumberTextField: UITextField!\n+    \n+    override func viewDidLoad() {\n+        super.viewDidLoad()\n+        \n+        //sets format number style to currency\n+        _currencyFormatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle\n+        \n+        //set delegate for dollarnumberUITextField\n+        self.dollarNumberTextField.delegate = self\n+        \n+        //get current dollar price from fixer.io\n+        getCurrencyValues(self.updateValues)\n+        \n+        // Gesture that recognices tap to hide keyboard\n+        let tapGesture = UITapGestureRecognizer(target: self, action:Selector(\"endEditing:\"))\n+        tapGesture.cancelsTouchesInView = false\n+        self.view.addGestureRecognizer(tapGesture);\n+    }\n+    \n+    // fetches exchange values for dollar using a get request and receiving a callback\n+    func getCurrencyValues(completion: (() -> Void)!) {\n+        \n+        // Create NSURL Ibject\n+        let pricesUrl = NSURL(string: EXCHANGESURL);\n+        \n+        // Creaste URL Request\n+        let pricesRequest = NSMutableURLRequest(URL:pricesUrl!);\n+        \n+        // Set request HTTP method to GET. It could be POST as well\n+        pricesRequest.HTTPMethod = REQUESTMETHOD\n+        \n+        // Excute HTTP Request\n+        let task = NSURLSession.sharedSession().dataTaskWithRequest(pricesRequest) {\n+            data, response, error in\n+            \n+            // Check for error\n+            if error != nil\n+            {\n+                print(\"error=\\(error)\")\n+                return\n+            }\n+            \n+            // Print out response string\n+            let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)\n+            print(\"responseString = \\(responseString)\")\n+            \n+            \n+            // Convert server json response to NSDictionary\n+            do {\n+                if let convertedJsonIntoDict = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as? NSDictionary {\n+                    \n+                    self._requestedWasOk = true\n+                    \n+                    self._exchangesDictionary = convertedJsonIntoDict[\"rates\"] as? [String : Double]\n+                    \n+                    completion() //callback\n+                    \n+                }\n+            } catch let error as NSError {\n+                print(error.localizedDescription)\n+                \n+                self._requestedWasOk = false\n+            }","path":"ConverterViewController.swift","position":99,"original_position":99,"commit_id":"ff7595c4c6f4de32fb4bebab13dedfd4f99677d3","original_commit_id":"ff7595c4c6f4de32fb4bebab13dedfd4f99677d3","user":{"login":"darincon","id":19197321,"avatar_url":"https://avatars.githubusercontent.com/u/19197321?v=3","gravatar_id":"","url":"https://api.github.com/users/darincon","html_url":"https://github.com/darincon","followers_url":"https://api.github.com/users/darincon/followers","following_url":"https://api.github.com/users/darincon/following{/other_user}","gists_url":"https://api.github.com/users/darincon/gists{/gist_id}","starred_url":"https://api.github.com/users/darincon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darincon/subscriptions","organizations_url":"https://api.github.com/users/darincon/orgs","repos_url":"https://api.github.com/users/darincon/repos","events_url":"https://api.github.com/users/darincon/events{/privacy}","received_events_url":"https://api.github.com/users/darincon/received_events","type":"User","site_admin":false},"body":"You are not calling the completion block if there's an error, which may lead to the UI waiting forever for a response that never came. In this cases what we usually do is to have a closure that passes the expected result and an error. Both are optional so we can pass `nil` if needed","created_at":"2016-08-10T22:04:44Z","updated_at":"2016-08-10T22:04:44Z","html_url":"https://github.com/fabianmarinog/AnArmyOfOne/pull/2#discussion_r74339878","pull_request_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/comments/74339878"},"html":{"href":"https://github.com/fabianmarinog/AnArmyOfOne/pull/2#discussion_r74339878"},"pull_request":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/2","id":66867202,"html_url":"https://github.com/fabianmarinog/AnArmyOfOne/pull/2","diff_url":"https://github.com/fabianmarinog/AnArmyOfOne/pull/2.diff","patch_url":"https://github.com/fabianmarinog/AnArmyOfOne/pull/2.patch","issue_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues/2","number":2,"state":"open","locked":false,"title":"New develop branch for multiple collaborators review.","user":{"login":"fabianmarinog","id":668906,"avatar_url":"https://avatars.githubusercontent.com/u/668906?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianmarinog","html_url":"https://github.com/fabianmarinog","followers_url":"https://api.github.com/users/fabianmarinog/followers","following_url":"https://api.github.com/users/fabianmarinog/following{/other_user}","gists_url":"https://api.github.com/users/fabianmarinog/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianmarinog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianmarinog/subscriptions","organizations_url":"https://api.github.com/users/fabianmarinog/orgs","repos_url":"https://api.github.com/users/fabianmarinog/repos","events_url":"https://api.github.com/users/fabianmarinog/events{/privacy}","received_events_url":"https://api.github.com/users/fabianmarinog/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-18T14:54:54Z","updated_at":"2016-08-10T22:04:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f2606d78977f2a4c708d99e1c6ca5c00e75a419","assignee":{"login":"darincon","id":19197321,"avatar_url":"https://avatars.githubusercontent.com/u/19197321?v=3","gravatar_id":"","url":"https://api.github.com/users/darincon","html_url":"https://github.com/darincon","followers_url":"https://api.github.com/users/darincon/followers","following_url":"https://api.github.com/users/darincon/following{/other_user}","gists_url":"https://api.github.com/users/darincon/gists{/gist_id}","starred_url":"https://api.github.com/users/darincon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darincon/subscriptions","organizations_url":"https://api.github.com/users/darincon/orgs","repos_url":"https://api.github.com/users/darincon/repos","events_url":"https://api.github.com/users/darincon/events{/privacy}","received_events_url":"https://api.github.com/users/darincon/received_events","type":"User","site_admin":false},"assignees":[{"login":"darincon","id":19197321,"avatar_url":"https://avatars.githubusercontent.com/u/19197321?v=3","gravatar_id":"","url":"https://api.github.com/users/darincon","html_url":"https://github.com/darincon","followers_url":"https://api.github.com/users/darincon/followers","following_url":"https://api.github.com/users/darincon/following{/other_user}","gists_url":"https://api.github.com/users/darincon/gists{/gist_id}","starred_url":"https://api.github.com/users/darincon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darincon/subscriptions","organizations_url":"https://api.github.com/users/darincon/orgs","repos_url":"https://api.github.com/users/darincon/repos","events_url":"https://api.github.com/users/darincon/events{/privacy}","received_events_url":"https://api.github.com/users/darincon/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/2/commits","review_comments_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/2/comments","review_comment_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues/2/comments","statuses_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/statuses/ff7595c4c6f4de32fb4bebab13dedfd4f99677d3","head":{"label":"fabianmarinog:new-develop","ref":"new-develop","sha":"ff7595c4c6f4de32fb4bebab13dedfd4f99677d3","user":{"login":"fabianmarinog","id":668906,"avatar_url":"https://avatars.githubusercontent.com/u/668906?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianmarinog","html_url":"https://github.com/fabianmarinog","followers_url":"https://api.github.com/users/fabianmarinog/followers","following_url":"https://api.github.com/users/fabianmarinog/following{/other_user}","gists_url":"https://api.github.com/users/fabianmarinog/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianmarinog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianmarinog/subscriptions","organizations_url":"https://api.github.com/users/fabianmarinog/orgs","repos_url":"https://api.github.com/users/fabianmarinog/repos","events_url":"https://api.github.com/users/fabianmarinog/events{/privacy}","received_events_url":"https://api.github.com/users/fabianmarinog/received_events","type":"User","site_admin":false},"repo":{"id":56348055,"name":"AnArmyOfOne","full_name":"fabianmarinog/AnArmyOfOne","owner":{"login":"fabianmarinog","id":668906,"avatar_url":"https://avatars.githubusercontent.com/u/668906?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianmarinog","html_url":"https://github.com/fabianmarinog","followers_url":"https://api.github.com/users/fabianmarinog/followers","following_url":"https://api.github.com/users/fabianmarinog/following{/other_user}","gists_url":"https://api.github.com/users/fabianmarinog/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianmarinog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianmarinog/subscriptions","organizations_url":"https://api.github.com/users/fabianmarinog/orgs","repos_url":"https://api.github.com/users/fabianmarinog/repos","events_url":"https://api.github.com/users/fabianmarinog/events{/privacy}","received_events_url":"https://api.github.com/users/fabianmarinog/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabianmarinog/AnArmyOfOne","description":"","fork":false,"url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne","forks_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/forks","keys_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/teams","hooks_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/hooks","issue_events_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues/events{/number}","events_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/events","assignees_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/assignees{/user}","branches_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/branches{/branch}","tags_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/tags","blobs_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/statuses/{sha}","languages_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/languages","stargazers_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/stargazers","contributors_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/contributors","subscribers_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/subscribers","subscription_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/subscription","commits_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/contents/{+path}","compare_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/merges","archive_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/downloads","issues_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues{/number}","pulls_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls{/number}","milestones_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/milestones{/number}","notifications_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/labels{/name}","releases_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/releases{/id}","deployments_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/deployments","created_at":"2016-04-15T20:32:03Z","updated_at":"2016-04-18T14:40:55Z","pushed_at":"2016-04-18T14:54:54Z","git_url":"git://github.com/fabianmarinog/AnArmyOfOne.git","ssh_url":"git@github.com:fabianmarinog/AnArmyOfOne.git","clone_url":"https://github.com/fabianmarinog/AnArmyOfOne.git","svn_url":"https://github.com/fabianmarinog/AnArmyOfOne","homepage":null,"size":252,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"fabianmarinog:master","ref":"master","sha":"72d3d4b87c508e7b29269a2e0baec5d3cd90c578","user":{"login":"fabianmarinog","id":668906,"avatar_url":"https://avatars.githubusercontent.com/u/668906?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianmarinog","html_url":"https://github.com/fabianmarinog","followers_url":"https://api.github.com/users/fabianmarinog/followers","following_url":"https://api.github.com/users/fabianmarinog/following{/other_user}","gists_url":"https://api.github.com/users/fabianmarinog/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianmarinog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianmarinog/subscriptions","organizations_url":"https://api.github.com/users/fabianmarinog/orgs","repos_url":"https://api.github.com/users/fabianmarinog/repos","events_url":"https://api.github.com/users/fabianmarinog/events{/privacy}","received_events_url":"https://api.github.com/users/fabianmarinog/received_events","type":"User","site_admin":false},"repo":{"id":56348055,"name":"AnArmyOfOne","full_name":"fabianmarinog/AnArmyOfOne","owner":{"login":"fabianmarinog","id":668906,"avatar_url":"https://avatars.githubusercontent.com/u/668906?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianmarinog","html_url":"https://github.com/fabianmarinog","followers_url":"https://api.github.com/users/fabianmarinog/followers","following_url":"https://api.github.com/users/fabianmarinog/following{/other_user}","gists_url":"https://api.github.com/users/fabianmarinog/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianmarinog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianmarinog/subscriptions","organizations_url":"https://api.github.com/users/fabianmarinog/orgs","repos_url":"https://api.github.com/users/fabianmarinog/repos","events_url":"https://api.github.com/users/fabianmarinog/events{/privacy}","received_events_url":"https://api.github.com/users/fabianmarinog/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabianmarinog/AnArmyOfOne","description":"","fork":false,"url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne","forks_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/forks","keys_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/teams","hooks_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/hooks","issue_events_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues/events{/number}","events_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/events","assignees_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/assignees{/user}","branches_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/branches{/branch}","tags_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/tags","blobs_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/statuses/{sha}","languages_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/languages","stargazers_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/stargazers","contributors_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/contributors","subscribers_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/subscribers","subscription_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/subscription","commits_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/contents/{+path}","compare_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/merges","archive_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/downloads","issues_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues{/number}","pulls_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls{/number}","milestones_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/milestones{/number}","notifications_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/labels{/name}","releases_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/releases{/id}","deployments_url":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/deployments","created_at":"2016-04-15T20:32:03Z","updated_at":"2016-04-18T14:40:55Z","pushed_at":"2016-04-18T14:54:54Z","git_url":"git://github.com/fabianmarinog/AnArmyOfOne.git","ssh_url":"git@github.com:fabianmarinog/AnArmyOfOne.git","clone_url":"https://github.com/fabianmarinog/AnArmyOfOne.git","svn_url":"https://github.com/fabianmarinog/AnArmyOfOne","homepage":null,"size":252,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/2"},"html":{"href":"https://github.com/fabianmarinog/AnArmyOfOne/pull/2"},"issue":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues/2"},"comments":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/fabianmarinog/AnArmyOfOne/statuses/ff7595c4c6f4de32fb4bebab13dedfd4f99677d3"}}}}
{"actor":{"display_login":"darincon"}}