The NSSharingServicePicker class presents a list of sharing services, so that the user can choose a service to share an item. When a service is chosen, the picker automatically executes it, which presents the sharing window.
+ (NSMenu *)menuForSharingItems:(NSArray *)items
withTarget:(id)target //the target to which aSel will be sent to
selector:(SEL)aSel //aSel like: mySelector:(NSMenuItem *)it -> it.representedObject = service according to menu item title.
serviceDelegate:(id <NSSharingServiceDelegate>)del
{
NSArray *sharingServices = [NSSharingService sharingServicesForItems:items];
if (sharingServices.count == 0)
return nil;
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"MountainLionSharingMenu"];
// rebuild the menu
for (NSSharingService *currentService in sharingServices)
{
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:currentService.title action:aSel keyEquivalent:@""];
item.image = currentService.image;
item.representedObject = currentService;
currentService.delegate = del;
item.target = target;
[menu addItem:item];
#if !__has_feature(objc_arc)
[item release];
#endif
}
#if !__has_feature(objc_arc)
return [menu autorelease];
#else
return menu;
#endif
}
0 Comment(s)