title: Accessing user profile picture from iCloud account
body: <p>I'm attempting to pull a user's profile picture from their iCloud account. I'm using CloudKit and am verifying the user has an iCloud account as well as requesting discoverability permissions. I'm not sure this is possible but if it is I'd like to know how. Here is the relevant code:</p>
  
  <p>To verify iCloud account:</p>
  
  <pre><code>[[CKContainer defaultContainer] accountStatusWithCompletionHandler:^(CKAccountStatus accountStatus, NSError *error) {
      if (accountStatus == CKAccountStatusAvailable)
      {
          self.shouldLogin = YES;
      }
      else
      {
          self.shouldLogin = NO;
      }
  }];
  </code></pre>
  
  <p>To pull their profile image out of their iCloud account:</p>
  
  <pre><code>    [[CKContainer defaultContainer] requestApplicationPermission:CKApplicationPermissionUserDiscoverability completionHandler:^(CKApplicationPermissionStatus applicationPermissionStatus, NSError * _Nullable error) {
      if (applicationPermissionStatus == CKApplicationPermissionStatusGranted)
      {
          [[CKContainer defaultContainer] discoverUserInfoWithUserRecordID:self.dataStore.user.userID completionHandler:^(CKDiscoveredUserInfo * _Nullable userInfo, NSError * _Nullable error) {
              NSData *imageData = userInfo.displayContact.imageData;
              UIImage *profileImage = [UIImage imageWithData:imageData];
              self.profileImageView.image = profileImage;
          }];
      }
  }];
  </code></pre>