{"action":"created","comment":{"url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/comments/55214093","id":55214093,"diff_hunk":"@@ -0,0 +1,111 @@\n+//\n+//  ViewController.m\n+//  FlickrViewer\n+//\n+//  Created by Michael Kupchick on 3/2/16.\n+//  Copyright © 2016 Michael Kupchick. All rights reserved.\n+//\n+\n+#import \"MainViewController.h\"\n+\n+#import \"ImageDataProvider.h\"\n+#import \"PhotoRecord.h\"\n+#import \"PhotosSourceFlickr.h\"\n+#import \"PlaceRecord.h\"\n+#import \"PlacesSourceFlickr.h\"\n+#import \"ScrollViewController.h\"\n+\n+NS_ASSUME_NONNULL_BEGIN\n+\n+@interface MainViewController ()\n+\n+/// URL session to perform the network operations on\n+@property (strong, nonatomic) NSURLSession *session;\n+\n+/// Scroll view controller that loads and presents the image\n+@property (strong, nonatomic) ScrollViewController *scrollViewController;\n+\n+/// Activity indicator to show the downaload process\n+@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;\n+\n+@end\n+\n+@implementation MainViewController\n+\n+- (void)viewWillAppear:(BOOL)animated {\n+  [super viewWillAppear:animated];\n+  \n+  self.activityIndicator.hidesWhenStopped = YES;\n+  self.activityIndicator.hidden = YES;\n+  [self.activityIndicator startAnimating];\n+  \n+  /// Since all requests are cancellable async operations with completions\n+  ///we will chain them together using completion blocks.\n+  \n+  /// First getting Flickr top places.\n+  PlacesSourceFlickr *placesSource = [[PlacesSourceFlickr alloc] initWithURLSession:self.session];\n+  \n+  [placesSource requestPlaceRecordsWithMaxCount:1\n+                                 withCompletion:^(NSArray * _Nullable placeRecords,\n+                                                  NSError * _Nullable error) {\n+   if (error || placeRecords.count == 0) {\n+     return;\n+   }\n+   \n+   /// Getting first photo for the first top place.\n+   PlaceRecord *topPlace = (PlaceRecord *)placeRecords[0];\n+   \n+   PhotosSourceFlickrByPlace *photoSource =\n+       [[PhotosSourceFlickrByPlace alloc] initWithPlaceID:topPlace.placeID\n+                                           andWithSession:self.session];\n+   \n+   [photoSource requestPhotoRecordsWithMaxCount:1\n+                                 withCompletion:^(NSArray * _Nullable photoRecords,\n+                                                  NSError * _Nullable error) {\n+      if (error || photoRecords.count == 0) {\n+        return;\n+      }\n+     \n+      PhotoRecord *topPhoto = (PhotoRecord *)photoRecords[0];\n+      \n+      [self showPhotoFromURL:topPhoto.url];\n+    }];\n+  }];\n+}\n+\n+- (void)showPhotoFromURL:(NSURL *)url {\n+  /// Photo downloading is handled by scrollview controller so redirecting the request there.\n+  [self.scrollViewController loadImageFromURL:url\n+                               withCompletion:^(NSURL * _Nonnull imageURL,","path":"FlickrViewer/View/MainViewController.m","position":79,"original_position":79,"commit_id":"9836154db35c2ce5d268109cd0c2c6ab29b54a4b","original_commit_id":"9836154db35c2ce5d268109cd0c2c6ab29b54a4b","user":{"login":"michaellightricks","id":17297304,"avatar_url":"https://avatars.githubusercontent.com/u/17297304?v=3","gravatar_id":"","url":"https://api.github.com/users/michaellightricks","html_url":"https://github.com/michaellightricks","followers_url":"https://api.github.com/users/michaellightricks/followers","following_url":"https://api.github.com/users/michaellightricks/following{/other_user}","gists_url":"https://api.github.com/users/michaellightricks/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellightricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellightricks/subscriptions","organizations_url":"https://api.github.com/users/michaellightricks/orgs","repos_url":"https://api.github.com/users/michaellightricks/repos","events_url":"https://api.github.com/users/michaellightricks/events{/privacy}","received_events_url":"https://api.github.com/users/michaellightricks/received_events","type":"User","site_admin":false},"body":"done","created_at":"2016-03-07T14:58:30Z","updated_at":"2016-03-07T14:58:30Z","html_url":"https://github.com/amit-goldstein/FlickrMichael/pull/3#discussion_r55214093","pull_request_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/comments/55214093"},"html":{"href":"https://github.com/amit-goldstein/FlickrMichael/pull/3#discussion_r55214093"},"pull_request":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/3","id":61842349,"html_url":"https://github.com/amit-goldstein/FlickrMichael/pull/3","diff_url":"https://github.com/amit-goldstein/FlickrMichael/pull/3.diff","patch_url":"https://github.com/amit-goldstein/FlickrMichael/pull/3.patch","issue_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/issues/3","number":3,"state":"open","locked":false,"title":"Feature/part2","user":{"login":"michaellightricks","id":17297304,"avatar_url":"https://avatars.githubusercontent.com/u/17297304?v=3","gravatar_id":"","url":"https://api.github.com/users/michaellightricks","html_url":"https://github.com/michaellightricks","followers_url":"https://api.github.com/users/michaellightricks/followers","following_url":"https://api.github.com/users/michaellightricks/following{/other_user}","gists_url":"https://api.github.com/users/michaellightricks/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellightricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellightricks/subscriptions","organizations_url":"https://api.github.com/users/michaellightricks/orgs","repos_url":"https://api.github.com/users/michaellightricks/repos","events_url":"https://api.github.com/users/michaellightricks/events{/privacy}","received_events_url":"https://api.github.com/users/michaellightricks/received_events","type":"User","site_admin":false},"body":"Finalize the overall implementation of exercise's part 2.","created_at":"2016-03-06T13:11:07Z","updated_at":"2016-03-07T14:58:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df566c833e1693448f8edbaaaf3d6a4eb97f67f4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/3/commits","review_comments_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/3/comments","review_comment_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/issues/3/comments","statuses_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/statuses/9836154db35c2ce5d268109cd0c2c6ab29b54a4b","head":{"label":"michaellightricks:feature/part2","ref":"feature/part2","sha":"9836154db35c2ce5d268109cd0c2c6ab29b54a4b","user":{"login":"michaellightricks","id":17297304,"avatar_url":"https://avatars.githubusercontent.com/u/17297304?v=3","gravatar_id":"","url":"https://api.github.com/users/michaellightricks","html_url":"https://github.com/michaellightricks","followers_url":"https://api.github.com/users/michaellightricks/followers","following_url":"https://api.github.com/users/michaellightricks/following{/other_user}","gists_url":"https://api.github.com/users/michaellightricks/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellightricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellightricks/subscriptions","organizations_url":"https://api.github.com/users/michaellightricks/orgs","repos_url":"https://api.github.com/users/michaellightricks/repos","events_url":"https://api.github.com/users/michaellightricks/events{/privacy}","received_events_url":"https://api.github.com/users/michaellightricks/received_events","type":"User","site_admin":false},"repo":{"id":52790915,"name":"FlickrMichael","full_name":"michaellightricks/FlickrMichael","owner":{"login":"michaellightricks","id":17297304,"avatar_url":"https://avatars.githubusercontent.com/u/17297304?v=3","gravatar_id":"","url":"https://api.github.com/users/michaellightricks","html_url":"https://github.com/michaellightricks","followers_url":"https://api.github.com/users/michaellightricks/followers","following_url":"https://api.github.com/users/michaellightricks/following{/other_user}","gists_url":"https://api.github.com/users/michaellightricks/gists{/gist_id}","starred_url":"https://api.github.com/users/michaellightricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaellightricks/subscriptions","organizations_url":"https://api.github.com/users/michaellightricks/orgs","repos_url":"https://api.github.com/users/michaellightricks/repos","events_url":"https://api.github.com/users/michaellightricks/events{/privacy}","received_events_url":"https://api.github.com/users/michaellightricks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michaellightricks/FlickrMichael","description":"Flickr Exercise for Michael K.","fork":true,"url":"https://api.github.com/repos/michaellightricks/FlickrMichael","forks_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/forks","keys_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/teams","hooks_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/hooks","issue_events_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/issues/events{/number}","events_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/events","assignees_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/assignees{/user}","branches_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/branches{/branch}","tags_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/tags","blobs_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/git/refs{/sha}","trees_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/statuses/{sha}","languages_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/languages","stargazers_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/stargazers","contributors_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/contributors","subscribers_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/subscribers","subscription_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/subscription","commits_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/commits{/sha}","git_commits_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/git/commits{/sha}","comments_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/comments{/number}","issue_comment_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/issues/comments{/number}","contents_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/contents/{+path}","compare_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/merges","archive_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/downloads","issues_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/issues{/number}","pulls_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/pulls{/number}","milestones_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/milestones{/number}","notifications_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/labels{/name}","releases_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/releases{/id}","deployments_url":"https://api.github.com/repos/michaellightricks/FlickrMichael/deployments","created_at":"2016-02-29T12:55:26Z","updated_at":"2016-02-29T12:34:13Z","pushed_at":"2016-03-07T12:48:44Z","git_url":"git://github.com/michaellightricks/FlickrMichael.git","ssh_url":"git@github.com:michaellightricks/FlickrMichael.git","clone_url":"https://github.com/michaellightricks/FlickrMichael.git","svn_url":"https://github.com/michaellightricks/FlickrMichael","homepage":null,"size":44,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"amit-goldstein:develop","ref":"develop","sha":"2d610e25461f901643e15fb42ce91ba60a5c734e","user":{"login":"amit-goldstein","id":3172498,"avatar_url":"https://avatars.githubusercontent.com/u/3172498?v=3","gravatar_id":"","url":"https://api.github.com/users/amit-goldstein","html_url":"https://github.com/amit-goldstein","followers_url":"https://api.github.com/users/amit-goldstein/followers","following_url":"https://api.github.com/users/amit-goldstein/following{/other_user}","gists_url":"https://api.github.com/users/amit-goldstein/gists{/gist_id}","starred_url":"https://api.github.com/users/amit-goldstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amit-goldstein/subscriptions","organizations_url":"https://api.github.com/users/amit-goldstein/orgs","repos_url":"https://api.github.com/users/amit-goldstein/repos","events_url":"https://api.github.com/users/amit-goldstein/events{/privacy}","received_events_url":"https://api.github.com/users/amit-goldstein/received_events","type":"User","site_admin":false},"repo":{"id":52789708,"name":"FlickrMichael","full_name":"amit-goldstein/FlickrMichael","owner":{"login":"amit-goldstein","id":3172498,"avatar_url":"https://avatars.githubusercontent.com/u/3172498?v=3","gravatar_id":"","url":"https://api.github.com/users/amit-goldstein","html_url":"https://github.com/amit-goldstein","followers_url":"https://api.github.com/users/amit-goldstein/followers","following_url":"https://api.github.com/users/amit-goldstein/following{/other_user}","gists_url":"https://api.github.com/users/amit-goldstein/gists{/gist_id}","starred_url":"https://api.github.com/users/amit-goldstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amit-goldstein/subscriptions","organizations_url":"https://api.github.com/users/amit-goldstein/orgs","repos_url":"https://api.github.com/users/amit-goldstein/repos","events_url":"https://api.github.com/users/amit-goldstein/events{/privacy}","received_events_url":"https://api.github.com/users/amit-goldstein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amit-goldstein/FlickrMichael","description":"Flickr Exercise for Michael K.","fork":false,"url":"https://api.github.com/repos/amit-goldstein/FlickrMichael","forks_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/forks","keys_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/teams","hooks_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/hooks","issue_events_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/issues/events{/number}","events_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/events","assignees_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/assignees{/user}","branches_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/branches{/branch}","tags_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/tags","blobs_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/git/refs{/sha}","trees_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/statuses/{sha}","languages_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/languages","stargazers_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/stargazers","contributors_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/contributors","subscribers_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/subscribers","subscription_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/subscription","commits_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/commits{/sha}","git_commits_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/git/commits{/sha}","comments_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/comments{/number}","issue_comment_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/issues/comments{/number}","contents_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/contents/{+path}","compare_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/merges","archive_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/downloads","issues_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/issues{/number}","pulls_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls{/number}","milestones_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/milestones{/number}","notifications_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/labels{/name}","releases_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/releases{/id}","deployments_url":"https://api.github.com/repos/amit-goldstein/FlickrMichael/deployments","created_at":"2016-02-29T12:34:13Z","updated_at":"2016-02-29T12:34:13Z","pushed_at":"2016-03-07T12:48:45Z","git_url":"git://github.com/amit-goldstein/FlickrMichael.git","ssh_url":"git@github.com:amit-goldstein/FlickrMichael.git","clone_url":"https://github.com/amit-goldstein/FlickrMichael.git","svn_url":"https://github.com/amit-goldstein/FlickrMichael","homepage":null,"size":2,"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":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/3"},"html":{"href":"https://github.com/amit-goldstein/FlickrMichael/pull/3"},"issue":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/issues/3"},"comments":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/amit-goldstein/FlickrMichael/statuses/9836154db35c2ce5d268109cd0c2c6ab29b54a4b"}}}}