sharingService(_:sourceWindowForShareItems:sharingContentScope:)
Returns the window that contained the share items.
Declaration
@MainActor optional func sharingService(_ sharingService: NSSharingService, sourceWindowForShareItems items: [Any], sharingContentScope: UnsafeMutablePointer<NSSharingService.SharingContentScope>) -> NSWindow?Parameters
- sharingService:
The sharing service.
- items:
The items being shared.
- sharingContentScope:
The sharing content scope. The sharing scope can be modified from the default value of Item by setting a different value in the out parameter
sharingContentScope. See Sharingcontentscope for supported values.
Return Value
The window of the shared items.
Discussion
The following is an example implementation of this method. It changes the item scope, and returns the window the source image view is contained within.
- (NSWindow *)sharingService:(NSSharingService *)sharingService
sourceWindowForShareItems:(NSArray *)items
sharingContentScope:(NSSharingContentScope *)sharingContentScope
{
*sharingContentScope = NSSharingContentScopeItem;
return [_imageView window];
}