{"action":"created","comment":{"url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/comments/48328535","id":48328535,"diff_hunk":"@@ -0,0 +1,102 @@\n+// Copyright (c) 2015 Lightricks. All rights reserved.\n+// Created by Shachar Langbeheim.\n+\n+#import \"Locations.h\"\n+\n+#import \"LocationInfo.h\"\n+\n+NS_ASSUME_NONNULL_BEGIN\n+\n+@interface Locations()\n+// Dictionary in which the keys are countries' names\n+// and the values are arrays of locations in those countries.\n+@property (strong, nonatomic) NSDictionary *locationsInfoByCountryName;\n+\n+// Array of names of keys in locationsInfoByCountryName, sorted alphabetically.\n+@property (strong, nonatomic) NSArray *sortedCountryNames;\n+@end\n+\n+@implementation Locations\n+#pragma mark -\n+#pragma mark - Instantiation\n+#pragma mark -\n+\n+- (instancetype)initWithLocations:(NSArray *)locations {\n+  if(self = [super init]) {\n+    // sort all locations into their respective countries\n+    NSMutableDictionary *locationsInfoByCountry = [[NSMutableDictionary alloc] init];\n+    for(NSDictionary *location in locations) {\n+      LocationInfo *locationInfo = [[LocationInfo alloc] initWithUnparsedLocationInfo:location];\n+      NSMutableArray *locationsForGivenCountry = locationsInfoByCountry[locationInfo.countryName];\n+      // if there's no entry for this country, create a new array\n+      if(!locationsForGivenCountry) {\n+        locationsForGivenCountry = [[NSMutableArray alloc] init];\n+        [locationsInfoByCountry setObject:locationsForGivenCountry\n+                                        forKey:locationInfo.countryName];\n+      }\n+      [locationsForGivenCountry addObject:locationInfo];\n+    }\n+    \n+    // sort the locations in each country according to region and name.\n+    NSMutableDictionary *sortedLocationsInfoByCountry = [[NSMutableDictionary alloc] init];\n+    for(NSString *countryName in [locationsInfoByCountry allKeys]) {\n+      NSArray *locationsInfo = locationsInfoByCountry[countryName];\n+      sortedLocationsInfoByCountry[countryName] = [locationsInfo sortedArrayUsingComparator:\n+        ^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {\n+          LocationInfo *first = obj1;\n+          LocationInfo *second = obj2;\n+          NSComparisonResult regioncomparison =\n+          [first.regionName localizedCaseInsensitiveCompare:second.regionName];\n+          if(regioncomparison != NSOrderedSame) {\n+            return regioncomparison;\n+          }\n+          \n+          return [first.locationName localizedCaseInsensitiveCompare:second.locationName];\n+      }];\n+    }\n+    \n+    self.locationsInfoByCountryName = sortedLocationsInfoByCountry;\n+    self.sortedCountryNames = [[self.locationsInfoByCountryName allKeys]\n+        sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];\n+  }\n+  \n+  return self;\n+}\n+\n+#pragma mark -\n+#pragma mark - Locations public interface\n+#pragma mark -\n+\n+- (NSString *)locationName:(NSInteger)locationIndex inCountryIndex:(NSInteger)countryIndex {\n+  return [self locationAtIndex:locationIndex inCountry:countryIndex].locationName;\n+}\n+\n+- (NSString *)regionName:(NSInteger)locationIndex inCountryIndex:(NSInteger)countryIndex {\n+  return [self locationAtIndex:locationIndex inCountry:countryIndex].regionName;\n+}\n+\n+- (NSString *)countryName:(NSInteger)countryIndex {\n+  return self.sortedCountryNames[countryIndex];\n+}\n+\n+- (NSInteger)numberOfCountries {","path":"Exercise5/Model/Locations.m","position":82,"original_position":82,"commit_id":"fdfc10ce492df8332ad8be3818c878f36b7fdfa8","original_commit_id":"fdfc10ce492df8332ad8be3818c878f36b7fdfa8","user":{"login":"CodeBaseCamp","id":7971250,"avatar_url":"https://avatars.githubusercontent.com/u/7971250?v=3","gravatar_id":"","url":"https://api.github.com/users/CodeBaseCamp","html_url":"https://github.com/CodeBaseCamp","followers_url":"https://api.github.com/users/CodeBaseCamp/followers","following_url":"https://api.github.com/users/CodeBaseCamp/following{/other_user}","gists_url":"https://api.github.com/users/CodeBaseCamp/gists{/gist_id}","starred_url":"https://api.github.com/users/CodeBaseCamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodeBaseCamp/subscriptions","organizations_url":"https://api.github.com/users/CodeBaseCamp/orgs","repos_url":"https://api.github.com/users/CodeBaseCamp/repos","events_url":"https://api.github.com/users/CodeBaseCamp/events{/privacy}","received_events_url":"https://api.github.com/users/CodeBaseCamp/received_events","type":"User","site_admin":false},"body":"Move below\r\n```\r\n#pragma mark -\r\n#pragma mark - Properties\r\n#pragma mark -\r\n```\r\nafter transforming to property in `h` file.","created_at":"2015-12-23T08:28:47Z","updated_at":"2015-12-23T08:28:47Z","html_url":"https://github.com/CodeBaseCamp/Assignment_5_Shachar/pull/5#discussion_r48328535","pull_request_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/comments/48328535"},"html":{"href":"https://github.com/CodeBaseCamp/Assignment_5_Shachar/pull/5#discussion_r48328535"},"pull_request":{"href":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/5","id":54372197,"html_url":"https://github.com/CodeBaseCamp/Assignment_5_Shachar/pull/5","diff_url":"https://github.com/CodeBaseCamp/Assignment_5_Shachar/pull/5.diff","patch_url":"https://github.com/CodeBaseCamp/Assignment_5_Shachar/pull/5.patch","issue_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/issues/5","number":5,"state":"open","locked":false,"title":"Top places view controller, Flickr fetching API & location models.","user":{"login":"Shachlan","id":16204012,"avatar_url":"https://avatars.githubusercontent.com/u/16204012?v=3","gravatar_id":"","url":"https://api.github.com/users/Shachlan","html_url":"https://github.com/Shachlan","followers_url":"https://api.github.com/users/Shachlan/followers","following_url":"https://api.github.com/users/Shachlan/following{/other_user}","gists_url":"https://api.github.com/users/Shachlan/gists{/gist_id}","starred_url":"https://api.github.com/users/Shachlan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shachlan/subscriptions","organizations_url":"https://api.github.com/users/Shachlan/orgs","repos_url":"https://api.github.com/users/Shachlan/repos","events_url":"https://api.github.com/users/Shachlan/events{/privacy}","received_events_url":"https://api.github.com/users/Shachlan/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-22T14:00:16Z","updated_at":"2015-12-23T08:28:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"920774f7bae8a68caa9d591268955469ee593242","assignee":{"login":"CodeBaseCamp","id":7971250,"avatar_url":"https://avatars.githubusercontent.com/u/7971250?v=3","gravatar_id":"","url":"https://api.github.com/users/CodeBaseCamp","html_url":"https://github.com/CodeBaseCamp","followers_url":"https://api.github.com/users/CodeBaseCamp/followers","following_url":"https://api.github.com/users/CodeBaseCamp/following{/other_user}","gists_url":"https://api.github.com/users/CodeBaseCamp/gists{/gist_id}","starred_url":"https://api.github.com/users/CodeBaseCamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodeBaseCamp/subscriptions","organizations_url":"https://api.github.com/users/CodeBaseCamp/orgs","repos_url":"https://api.github.com/users/CodeBaseCamp/repos","events_url":"https://api.github.com/users/CodeBaseCamp/events{/privacy}","received_events_url":"https://api.github.com/users/CodeBaseCamp/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/5/commits","review_comments_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/5/comments","review_comment_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/issues/5/comments","statuses_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/statuses/fdfc10ce492df8332ad8be3818c878f36b7fdfa8","head":{"label":"Shachlan:feature/top-places-table-view","ref":"feature/top-places-table-view","sha":"fdfc10ce492df8332ad8be3818c878f36b7fdfa8","user":{"login":"Shachlan","id":16204012,"avatar_url":"https://avatars.githubusercontent.com/u/16204012?v=3","gravatar_id":"","url":"https://api.github.com/users/Shachlan","html_url":"https://github.com/Shachlan","followers_url":"https://api.github.com/users/Shachlan/followers","following_url":"https://api.github.com/users/Shachlan/following{/other_user}","gists_url":"https://api.github.com/users/Shachlan/gists{/gist_id}","starred_url":"https://api.github.com/users/Shachlan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shachlan/subscriptions","organizations_url":"https://api.github.com/users/Shachlan/orgs","repos_url":"https://api.github.com/users/Shachlan/repos","events_url":"https://api.github.com/users/Shachlan/events{/privacy}","received_events_url":"https://api.github.com/users/Shachlan/received_events","type":"User","site_admin":false},"repo":{"id":48421200,"name":"Assignment_5_Shachar","full_name":"Shachlan/Assignment_5_Shachar","owner":{"login":"Shachlan","id":16204012,"avatar_url":"https://avatars.githubusercontent.com/u/16204012?v=3","gravatar_id":"","url":"https://api.github.com/users/Shachlan","html_url":"https://github.com/Shachlan","followers_url":"https://api.github.com/users/Shachlan/followers","following_url":"https://api.github.com/users/Shachlan/following{/other_user}","gists_url":"https://api.github.com/users/Shachlan/gists{/gist_id}","starred_url":"https://api.github.com/users/Shachlan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shachlan/subscriptions","organizations_url":"https://api.github.com/users/Shachlan/orgs","repos_url":"https://api.github.com/users/Shachlan/repos","events_url":"https://api.github.com/users/Shachlan/events{/privacy}","received_events_url":"https://api.github.com/users/Shachlan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Shachlan/Assignment_5_Shachar","description":"","fork":true,"url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar","forks_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/forks","keys_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/teams","hooks_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/hooks","issue_events_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/issues/events{/number}","events_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/events","assignees_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/assignees{/user}","branches_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/branches{/branch}","tags_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/tags","blobs_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/statuses/{sha}","languages_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/languages","stargazers_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/stargazers","contributors_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/contributors","subscribers_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/subscribers","subscription_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/subscription","commits_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/contents/{+path}","compare_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/merges","archive_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/downloads","issues_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/issues{/number}","pulls_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/pulls{/number}","milestones_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/milestones{/number}","notifications_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/labels{/name}","releases_url":"https://api.github.com/repos/Shachlan/Assignment_5_Shachar/releases{/id}","created_at":"2015-12-22T08:53:41Z","updated_at":"2015-12-22T08:35:03Z","pushed_at":"2015-12-22T13:59:28Z","git_url":"git://github.com/Shachlan/Assignment_5_Shachar.git","ssh_url":"git@github.com:Shachlan/Assignment_5_Shachar.git","clone_url":"https://github.com/Shachlan/Assignment_5_Shachar.git","svn_url":"https://github.com/Shachlan/Assignment_5_Shachar","homepage":null,"size":54,"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":"develop"}},"base":{"label":"CodeBaseCamp:develop","ref":"develop","sha":"90e17ad35ac00ecbc063c96d14c3921c1dd406a2","user":{"login":"CodeBaseCamp","id":7971250,"avatar_url":"https://avatars.githubusercontent.com/u/7971250?v=3","gravatar_id":"","url":"https://api.github.com/users/CodeBaseCamp","html_url":"https://github.com/CodeBaseCamp","followers_url":"https://api.github.com/users/CodeBaseCamp/followers","following_url":"https://api.github.com/users/CodeBaseCamp/following{/other_user}","gists_url":"https://api.github.com/users/CodeBaseCamp/gists{/gist_id}","starred_url":"https://api.github.com/users/CodeBaseCamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodeBaseCamp/subscriptions","organizations_url":"https://api.github.com/users/CodeBaseCamp/orgs","repos_url":"https://api.github.com/users/CodeBaseCamp/repos","events_url":"https://api.github.com/users/CodeBaseCamp/events{/privacy}","received_events_url":"https://api.github.com/users/CodeBaseCamp/received_events","type":"User","site_admin":false},"repo":{"id":48420231,"name":"Assignment_5_Shachar","full_name":"CodeBaseCamp/Assignment_5_Shachar","owner":{"login":"CodeBaseCamp","id":7971250,"avatar_url":"https://avatars.githubusercontent.com/u/7971250?v=3","gravatar_id":"","url":"https://api.github.com/users/CodeBaseCamp","html_url":"https://github.com/CodeBaseCamp","followers_url":"https://api.github.com/users/CodeBaseCamp/followers","following_url":"https://api.github.com/users/CodeBaseCamp/following{/other_user}","gists_url":"https://api.github.com/users/CodeBaseCamp/gists{/gist_id}","starred_url":"https://api.github.com/users/CodeBaseCamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodeBaseCamp/subscriptions","organizations_url":"https://api.github.com/users/CodeBaseCamp/orgs","repos_url":"https://api.github.com/users/CodeBaseCamp/repos","events_url":"https://api.github.com/users/CodeBaseCamp/events{/privacy}","received_events_url":"https://api.github.com/users/CodeBaseCamp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/CodeBaseCamp/Assignment_5_Shachar","description":"","fork":false,"url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar","forks_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/forks","keys_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/teams","hooks_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/hooks","issue_events_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/issues/events{/number}","events_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/events","assignees_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/assignees{/user}","branches_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/branches{/branch}","tags_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/tags","blobs_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/git/refs{/sha}","trees_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/statuses/{sha}","languages_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/languages","stargazers_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/stargazers","contributors_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/contributors","subscribers_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/subscribers","subscription_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/subscription","commits_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/commits{/sha}","git_commits_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/git/commits{/sha}","comments_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/comments{/number}","issue_comment_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/issues/comments{/number}","contents_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/contents/{+path}","compare_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/merges","archive_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/downloads","issues_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/issues{/number}","pulls_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls{/number}","milestones_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/milestones{/number}","notifications_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/labels{/name}","releases_url":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/releases{/id}","created_at":"2015-12-22T08:35:03Z","updated_at":"2015-12-22T08:35:03Z","pushed_at":"2015-12-22T14:00:16Z","git_url":"git://github.com/CodeBaseCamp/Assignment_5_Shachar.git","ssh_url":"git@github.com:CodeBaseCamp/Assignment_5_Shachar.git","clone_url":"https://github.com/CodeBaseCamp/Assignment_5_Shachar.git","svn_url":"https://github.com/CodeBaseCamp/Assignment_5_Shachar","homepage":null,"size":73,"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/CodeBaseCamp/Assignment_5_Shachar/pulls/5"},"html":{"href":"https://github.com/CodeBaseCamp/Assignment_5_Shachar/pull/5"},"issue":{"href":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/issues/5"},"comments":{"href":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/CodeBaseCamp/Assignment_5_Shachar/statuses/fdfc10ce492df8332ad8be3818c878f36b7fdfa8"}}}}