NSSharingServicePicker Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.8 and later. |
| Declared in | NSSharingService.h |
Overview
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.
The NSSharingServicePickerDelegate allows customizing the picker’s available services, where it appears, and allows assigning the delegate object for the NSSharingService delegate.
Tasks
Creating a Sharing Service Picker
Display the Sharing Service Picker
Getting and Setting the Delegate
-
delegateproperty
Properties
delegate
Specifies the service picker delegate.
Discussion
The delegate object must conform to the NSSharingServicePickerDelegate delegate.
Availability
- Available in OS X v10.8 and later.
Declared In
NSSharingService.hInstance Methods
initWithItems:
Initializes a new sharing service picker for the selected items.
Parameters
- items
The items to be shared.
Return Value
A configured sharing service picker.
Discussion
The items represent the objects to be shared and must conform to the NSPasteboardWriting protocol, for example, NSString, NSImage, NSURL, etc. If the one of the items is an NSURL instance is a file URL (pointing to a video for example), then the content of the file will be shared. If the URL is remote, then the URL itself will be shared.
Availability
- Available in OS X v10.8 and later.
Declared In
NSSharingService.hshowRelativeToRect:ofView:preferredEdge:
Shows the picker, populated with sharing services related to the instance items.
Parameters
- rect
The rectangle the picker should be showed relative to. The coordinates are in the view coordinate system. Passing
NSZeroRectcauses the view bounds to be used.- view
The view.
- preferredEdge
The preferred edge of the view to display the picker. See
NSRectEdgefor the possible values.
Discussion
When the user selects one of the sharing services, the sharing service will be performed. This method must be called on mouseDown using sendActionOn:NSLeftMouseDownMask.
The following is an example implementation:
- (IBAction)share:(id)sender |
{ |
NSArray * items = @[]; |
NSSharingServicePicker * picker = [[NSSharingServicePicker alloc] initWithItems:items]; |
picker.delegate = self; |
[picker showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge]; |
} |
Availability
- Available in OS X v10.8 and later.
Declared In
NSSharingService.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-23)