Since it seems there's no answer to that (filed http://openradar.appspot.com/16114564), I created a category
@implementation NSSharingService (ActivityType)
- (NSString*)activityType {
NSRange range = [self.description rangeOfString:@"\\[com.apple.share.*\\]" options:NSRegularExpressionSearch];
range.location++; // Start after [
range.length -= 2; // Remove both [ and ]
return [self.description substringWithRange:range];
}
@end
then you can use it these ways:
[[sharingService activityType] isEqualToString:NSSharingServiceNameAddToSafariReadingList];
[@[NSSharingServiceNameAddToSafariReadingList, NSSharingServiceNameAddToIPhoto]
containsObject:[sharingService activityType]];
I guess Apple just didn't think we'd want to know which service people picked from the Picker.
Obviously dangerous to parse that “com.apple.share.System” but it’s the only way I see to avoid a set of rangeOfString || rangeOfString || rangeOfString….
.
For more information check out https://github.com/stuffmc/SharingPicker
Also, as a reference, here are some of the values of those NSSharingServiceName*
constants, all starting with com.apple.share.
PostOnFacebook Facebook.post
PostOnTwitter Twitter.post
PostOnSinaWeibo SinaWeibo.post
PostOnTencentWeibo TencentWeibo.post
PostOnLinkedIn LinkedIn.post
ComposeEmail Mail.compose
ComposeMessage Messages.compose
SendViaAirDrop AirDrop.send
UseAsTwitterProfileImage Twitter.set-profile-image
UseAsFacebookProfileImage Facebook.set-profile-image
UseAsLinkedInProfileImage LinkedIn.set-profile-image
PostImageOnFlickr Video.upload-image-Flickr
AddToSafariReadingList System.add-to-safari-reading-list
AddToIPhoto System.add-to-iphoto