this method returns an array of dictionaries. Each dictionary consists of a status caption, whether not-determined ("non questioned"), sharing-denied ("denied"), or sharing-approved ("shared"), and an array of nutrition component names of nutrition components of that status.
171 int notDetermined = 0;
173 int itemAuthorized = 0;
174 NSMutableArray<NSMutableDictionary *> *notDeterminedTypes = [[NSMutableArray alloc] init];
175 NSMutableArray<NSMutableDictionary *> *deniedTypes = [[NSMutableArray alloc] init];
176 NSMutableArray<NSMutableDictionary *> *allowedTypes = [[NSMutableArray alloc] init];
184 NSMutableDictionary *componentData = [[NSMutableDictionary alloc] init];
185 [componentData setObject:nameData forKey:@"component-name"];
186 [componentData setObject:dateData forKey:@"component-authority-date"];
188 HKAuthorizationStatus status = [authorityData integerValue];
190 case HKAuthorizationStatusNotDetermined:
192 [notDeterminedTypes addObject:componentData];
195 case HKAuthorizationStatusSharingDenied:
197 [deniedTypes addObject:componentData];
200 case HKAuthorizationStatusSharingAuthorized:
202 [allowedTypes addObject:componentData];
207 NSMutableArray<NSDictionary *> *ret = [[NSMutableArray alloc] initWithCapacity:3];
208 NSNumber *statusNumb;
209 if (0 < notDetermined)
211 statusNumb = [NSNumber numberWithInt:HKAuthorizationStatusNotDetermined];
213 NSArray *statusTypes = [[NSArray alloc] initWithArray:notDeterminedTypes];
214 NSDictionary *notDeterminedElement = [[NSDictionary alloc] initWithObjectsAndKeys:@"not deteermined", @"HKAuthority-status-ident", statusTypes, @"HKAuthority-status-types", nil];
215 [ret addObject:notDeterminedElement];
219 statusNumb = [NSNumber numberWithInt:HKAuthorizationStatusSharingDenied];
221 NSArray *statusTypes = [[NSArray alloc] initWithArray:deniedTypes];
222 NSDictionary *sharingDeniedElement = [[NSDictionary alloc] initWithObjectsAndKeys:@"denied", @"HKAuthority-status-ident", statusTypes, @"HKAuthority-status-types", nil];
223 [ret addObject:sharingDeniedElement];
225 if (0 < itemAuthorized)
227 statusNumb = [NSNumber numberWithInt:HKAuthorizationStatusSharingAuthorized];
229 NSArray *statusTypes = [[NSArray alloc] initWithArray:allowedTypes];
230 NSDictionary *sharingApprovedElement = [[NSDictionary alloc] initWithObjectsAndKeys:@"authorized", @"HKAuthority-status-ident", statusTypes, @"HKAuthority-status-types", nil];
231 [ret addObject:sharingApprovedElement];
NSString * componentNameKey()
NSString * componentAuthorityDateKey()
NSMutableArray< NSDictionary * > * updatedAuthorityStatus
NSString * componentAuthorityKey()