{"action":"created","comment":{"url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/comments/48462404","id":48462404,"diff_hunk":"@@ -59,27 +59,32 @@ public extension UIView {\n     }\n     \n     /**\n-    More precise way of getting constraints for a view. The constraint does not have to belong to the reciever -- this method searches the superview for the matching constraint as well.\n-    \n-    :param: attribute     Attribute to look for belonging to the receiver\n-    :param: toItem        Probably a UIView, that the receiver is related to.\n-    :param: itemAttribute Attribute that should be used with the toItem\n-    \n-    :returns: The first constraint that matches. May return unexpected constraint if receiver contains multiple constraints with this item and itemAttribute.\n-    */\n-    public func ip_constraintForAttribute(attribute: NSLayoutAttribute, onView view1: UIView? = self, toView view2: UIView? = nil, viewAttribute: NSLayoutAttribute? = nil) -> NSLayoutConstraint? {\n+     More precise way of getting constraints for a view. The constraint does not have to belong to the reciever -- this method searches the superview for the matching constraint as well.\n+     \n+     :param: attribute     Attribute to look for belonging to the receiver\n+     :param: view1        Defaults to the receiver, but could be any subview as well.\n+     :param: view2        Probably a UIView, that view1 is related to.\n+     :param: viewAttribute Attribute that should be used with the toItem\n+     \n+     :returns: The first constraint that matches. May return unexpected constraint if receiver contains multiple constraints with this item and itemAttribute.\n+     */\n+    public func ip_constraintForAttribute(attribute: NSLayoutAttribute, var onView view1: UIView? = nil, toView view2: UIView? = nil, viewAttribute: NSLayoutAttribute? = nil) -> NSLayoutConstraint? {\n+        \n+        if view1 == nil {\n+            view1 = self\n+        }\n         \n-        if let toAttribute = itemAttribute, let toItem = view2 {\n+        if let toAttribute = viewAttribute, let toItem = view2 {\n             \n             return constraints.filter { constraint in\n-                return constraint.ip_relatesView(view: view1, viaAttribute: attribute, toView: toItem, andItsAttribute: toAttribute)\n+                return constraint.ip_relatesView(view: view1!, viaAttribute: attribute, toView: toItem, andItsAttribute: toAttribute)","path":"SwiftWisdom/SwiftWisdom/Core/UIKit/UIView+GetConstraints.swift","position":42,"original_position":42,"commit_id":"ac9ab388013cd1aa87b2828ed92ce9118a03a7c7","original_commit_id":"ac9ab388013cd1aa87b2828ed92ce9118a03a7c7","user":{"login":"LoganWright","id":5750489,"avatar_url":"https://avatars.githubusercontent.com/u/5750489?v=3","gravatar_id":"","url":"https://api.github.com/users/LoganWright","html_url":"https://github.com/LoganWright","followers_url":"https://api.github.com/users/LoganWright/followers","following_url":"https://api.github.com/users/LoganWright/following{/other_user}","gists_url":"https://api.github.com/users/LoganWright/gists{/gist_id}","starred_url":"https://api.github.com/users/LoganWright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LoganWright/subscriptions","organizations_url":"https://api.github.com/users/LoganWright/orgs","repos_url":"https://api.github.com/users/LoganWright/repos","events_url":"https://api.github.com/users/LoganWright/events{/privacy}","received_events_url":"https://api.github.com/users/LoganWright/received_events","type":"User","site_admin":false},"body":"Avoid unwrapping in this way in general, save `!` unwrapping only for a last resort.  Even though the current implementation, we can say that it will definitely exist, we shouldn't rely on it by human code comprehension.  We should let Swift handle it for us, so it can't reach this line of code unless `onView` (`view1`) has value.  This allows us to rely on its implementation here regardless of what happens above in future implementations since it won't build unless that condition is satisfied.","created_at":"2015-12-28T04:01:43Z","updated_at":"2015-12-28T04:01:43Z","html_url":"https://github.com/IntrepidPursuits/swift-wisdom/pull/16#discussion_r48462404","pull_request_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/comments/48462404"},"html":{"href":"https://github.com/IntrepidPursuits/swift-wisdom/pull/16#discussion_r48462404"},"pull_request":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/16","id":54606281,"html_url":"https://github.com/IntrepidPursuits/swift-wisdom/pull/16","diff_url":"https://github.com/IntrepidPursuits/swift-wisdom/pull/16.diff","patch_url":"https://github.com/IntrepidPursuits/swift-wisdom/pull/16.patch","issue_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues/16","number":16,"state":"open","locked":false,"title":"Previous GetConstraints had a lot of errors.","user":{"login":"paulrolfe","id":5570541,"avatar_url":"https://avatars.githubusercontent.com/u/5570541?v=3","gravatar_id":"","url":"https://api.github.com/users/paulrolfe","html_url":"https://github.com/paulrolfe","followers_url":"https://api.github.com/users/paulrolfe/followers","following_url":"https://api.github.com/users/paulrolfe/following{/other_user}","gists_url":"https://api.github.com/users/paulrolfe/gists{/gist_id}","starred_url":"https://api.github.com/users/paulrolfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulrolfe/subscriptions","organizations_url":"https://api.github.com/users/paulrolfe/orgs","repos_url":"https://api.github.com/users/paulrolfe/repos","events_url":"https://api.github.com/users/paulrolfe/events{/privacy}","received_events_url":"https://api.github.com/users/paulrolfe/received_events","type":"User","site_admin":false},"body":"I verified it works this time in bose-connect.","created_at":"2015-12-26T19:21:49Z","updated_at":"2015-12-28T04:01:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bed243fc3bcbac281aedff22b462cc2d85189683","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/16/commits","review_comments_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/16/comments","review_comment_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues/16/comments","statuses_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/statuses/ac9ab388013cd1aa87b2828ed92ce9118a03a7c7","head":{"label":"IntrepidPursuits:pr/constraint-fixes","ref":"pr/constraint-fixes","sha":"ac9ab388013cd1aa87b2828ed92ce9118a03a7c7","user":{"login":"IntrepidPursuits","id":2151424,"avatar_url":"https://avatars.githubusercontent.com/u/2151424?v=3","gravatar_id":"","url":"https://api.github.com/users/IntrepidPursuits","html_url":"https://github.com/IntrepidPursuits","followers_url":"https://api.github.com/users/IntrepidPursuits/followers","following_url":"https://api.github.com/users/IntrepidPursuits/following{/other_user}","gists_url":"https://api.github.com/users/IntrepidPursuits/gists{/gist_id}","starred_url":"https://api.github.com/users/IntrepidPursuits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IntrepidPursuits/subscriptions","organizations_url":"https://api.github.com/users/IntrepidPursuits/orgs","repos_url":"https://api.github.com/users/IntrepidPursuits/repos","events_url":"https://api.github.com/users/IntrepidPursuits/events{/privacy}","received_events_url":"https://api.github.com/users/IntrepidPursuits/received_events","type":"Organization","site_admin":false},"repo":{"id":39978693,"name":"swift-wisdom","full_name":"IntrepidPursuits/swift-wisdom","owner":{"login":"IntrepidPursuits","id":2151424,"avatar_url":"https://avatars.githubusercontent.com/u/2151424?v=3","gravatar_id":"","url":"https://api.github.com/users/IntrepidPursuits","html_url":"https://github.com/IntrepidPursuits","followers_url":"https://api.github.com/users/IntrepidPursuits/followers","following_url":"https://api.github.com/users/IntrepidPursuits/following{/other_user}","gists_url":"https://api.github.com/users/IntrepidPursuits/gists{/gist_id}","starred_url":"https://api.github.com/users/IntrepidPursuits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IntrepidPursuits/subscriptions","organizations_url":"https://api.github.com/users/IntrepidPursuits/orgs","repos_url":"https://api.github.com/users/IntrepidPursuits/repos","events_url":"https://api.github.com/users/IntrepidPursuits/events{/privacy}","received_events_url":"https://api.github.com/users/IntrepidPursuits/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/IntrepidPursuits/swift-wisdom","description":"A collection of additions to the Swift Standard Library created by Intrepid Pursuits Developers","fork":false,"url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom","forks_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/forks","keys_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/teams","hooks_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/hooks","issue_events_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues/events{/number}","events_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/events","assignees_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/assignees{/user}","branches_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/branches{/branch}","tags_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/tags","blobs_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/refs{/sha}","trees_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/statuses/{sha}","languages_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/languages","stargazers_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/stargazers","contributors_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/contributors","subscribers_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/subscribers","subscription_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/subscription","commits_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/commits{/sha}","git_commits_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/commits{/sha}","comments_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/comments{/number}","issue_comment_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues/comments{/number}","contents_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/contents/{+path}","compare_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/merges","archive_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/downloads","issues_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues{/number}","pulls_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls{/number}","milestones_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/milestones{/number}","notifications_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/labels{/name}","releases_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/releases{/id}","created_at":"2015-07-31T00:36:59Z","updated_at":"2015-12-01T15:41:53Z","pushed_at":"2015-12-26T19:21:49Z","git_url":"git://github.com/IntrepidPursuits/swift-wisdom.git","ssh_url":"git@github.com:IntrepidPursuits/swift-wisdom.git","clone_url":"https://github.com/IntrepidPursuits/swift-wisdom.git","svn_url":"https://github.com/IntrepidPursuits/swift-wisdom","homepage":null,"size":69,"stargazers_count":6,"watchers_count":6,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":6,"default_branch":"master"}},"base":{"label":"IntrepidPursuits:master","ref":"master","sha":"853e3361451a3830f0bc4c5dc90e65c36b20c157","user":{"login":"IntrepidPursuits","id":2151424,"avatar_url":"https://avatars.githubusercontent.com/u/2151424?v=3","gravatar_id":"","url":"https://api.github.com/users/IntrepidPursuits","html_url":"https://github.com/IntrepidPursuits","followers_url":"https://api.github.com/users/IntrepidPursuits/followers","following_url":"https://api.github.com/users/IntrepidPursuits/following{/other_user}","gists_url":"https://api.github.com/users/IntrepidPursuits/gists{/gist_id}","starred_url":"https://api.github.com/users/IntrepidPursuits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IntrepidPursuits/subscriptions","organizations_url":"https://api.github.com/users/IntrepidPursuits/orgs","repos_url":"https://api.github.com/users/IntrepidPursuits/repos","events_url":"https://api.github.com/users/IntrepidPursuits/events{/privacy}","received_events_url":"https://api.github.com/users/IntrepidPursuits/received_events","type":"Organization","site_admin":false},"repo":{"id":39978693,"name":"swift-wisdom","full_name":"IntrepidPursuits/swift-wisdom","owner":{"login":"IntrepidPursuits","id":2151424,"avatar_url":"https://avatars.githubusercontent.com/u/2151424?v=3","gravatar_id":"","url":"https://api.github.com/users/IntrepidPursuits","html_url":"https://github.com/IntrepidPursuits","followers_url":"https://api.github.com/users/IntrepidPursuits/followers","following_url":"https://api.github.com/users/IntrepidPursuits/following{/other_user}","gists_url":"https://api.github.com/users/IntrepidPursuits/gists{/gist_id}","starred_url":"https://api.github.com/users/IntrepidPursuits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IntrepidPursuits/subscriptions","organizations_url":"https://api.github.com/users/IntrepidPursuits/orgs","repos_url":"https://api.github.com/users/IntrepidPursuits/repos","events_url":"https://api.github.com/users/IntrepidPursuits/events{/privacy}","received_events_url":"https://api.github.com/users/IntrepidPursuits/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/IntrepidPursuits/swift-wisdom","description":"A collection of additions to the Swift Standard Library created by Intrepid Pursuits Developers","fork":false,"url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom","forks_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/forks","keys_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/teams","hooks_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/hooks","issue_events_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues/events{/number}","events_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/events","assignees_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/assignees{/user}","branches_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/branches{/branch}","tags_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/tags","blobs_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/refs{/sha}","trees_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/statuses/{sha}","languages_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/languages","stargazers_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/stargazers","contributors_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/contributors","subscribers_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/subscribers","subscription_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/subscription","commits_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/commits{/sha}","git_commits_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/git/commits{/sha}","comments_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/comments{/number}","issue_comment_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues/comments{/number}","contents_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/contents/{+path}","compare_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/merges","archive_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/downloads","issues_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues{/number}","pulls_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls{/number}","milestones_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/milestones{/number}","notifications_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/labels{/name}","releases_url":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/releases{/id}","created_at":"2015-07-31T00:36:59Z","updated_at":"2015-12-01T15:41:53Z","pushed_at":"2015-12-26T19:21:49Z","git_url":"git://github.com/IntrepidPursuits/swift-wisdom.git","ssh_url":"git@github.com:IntrepidPursuits/swift-wisdom.git","clone_url":"https://github.com/IntrepidPursuits/swift-wisdom.git","svn_url":"https://github.com/IntrepidPursuits/swift-wisdom","homepage":null,"size":69,"stargazers_count":6,"watchers_count":6,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/16"},"html":{"href":"https://github.com/IntrepidPursuits/swift-wisdom/pull/16"},"issue":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues/16"},"comments":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/IntrepidPursuits/swift-wisdom/statuses/ac9ab388013cd1aa87b2828ed92ce9118a03a7c7"}}}}