Thank you John and Darkwing for your help. John is correct in stating I am not a swifty.
Although the code posted by Darkwing is mostly gibberish to me, it did give me the clues I needed. Here are my results so far:
// set myself as the delegate
-(void)prepareSharingServicePicker:(NSSharingServicePicker *)sharingServicePicker {
[sharingServicePicker setDelegate:self];
}
-(NSArray<NSSharingService *> *)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker
sharingServicesForItems:(NSArray *)items
proposedSharingServices:(NSArray<NSSharingService *> *)proposedServices {
NSLog(@"proposed: %@",proposedServices);
/*
// This is the dump from the above NSLog
"<NSSharingService: 0x600000005ef0> [com.apple.share.Mail.compose] - enabled:YES",
"<NSSharingService: 0x600000005ed0> [com.apple.messages.ShareExtension] - enabled:YES",
"<NSSharingService: 0x600000005f00> [com.apple.share.AirDrop.send] - enabled:YES",
"<_NSCloudSharingService: 0x600002932d80> [com.apple.share.CloudSharing] - enabled:YES",
"<NSSharingService: 0x600000005ee0> [com.apple.Notes.SharingExtension] - enabled:YES"
*/
NSArray *myItems = [NSArray arrayWithObject:[proposedServices objectAtIndex:0]];
// as a hack to test it, I just put the mail service into the new array (myItems) and returned it.
// sure enough, the only thing that shows up in the share menu is the mail service. If I decide
// to use code like this, I would want to do a search in the array to make sure that the
// mail service is the object at index 0 since the order of them could be arbitrary.
// if you want to add something to the service menu, this code below will do it. You would want
// the array to include the above items and then add the custom service to it. This works
// even with the nil for the images although I get a warning. One would want real images.
// NSSharingService *customService = [[NSSharingService alloc] initWithTitle:@"Service Title"
// image:nil alternateImage:nil handler:^{ [self doCustomServiceWithItems:items]; }];
return myItems;
}
-(void)doCustomServiceWithItems:(NSArray *)items {
NSLog(@"do something");
}