Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Use of NSSharingServicePicker

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1.97k
    Comment on it

    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 !&#95;&#95;has&#95;feature(objc&#95;arc)
            [item release];
    #endif
        }
    #if !&#95;&#95;has&#95;feature(objc&#95;arc)
        return [menu autorelease];
    #else
        return menu;
    #endif
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: