使用NSSharingService定义邮件主题

时间:2012-10-30 15:17:32

标签: macos cocoa email osx-mountain-lion sharing

如何为使用NSSharingService组成的邮件消息定义主题?

我经历过NSSharingService Class reference,但我没有看到它在任何地方定义。以下成功启动邮件应用程序,但主题只是与文本一起推入邮件正文。

NSAttributedString *text = [self.noteSynopsisView attributedString];
NSString *subject = @"My Subject";
NSArray *shareItems = [NSArray arrayWithObjects:text, subject, nil];
NSSharingServicePicker *sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:shareItems];
sharingServicePicker.delegate = self;
[sharingServicePicker showRelativeToRect:[self.shareButton bounds] ofView:self.shareButton preferredEdge:NSMaxYEdge];

在iOS中,您通常会执行以下操作来定义MailComposer的主题

[sharingServicePicker setSubject:@"My Subject"];

但SharingServicePicker不支持setSubject。

2 个答案:

答案 0 :(得分:2)

自OS X 10.9起,NSSharingService具有subject属性,您可以使用。

答案 1 :(得分:0)

实施下一个方法:

-(id<NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService{
    sharingService.subject=@"Subject";
    return self;
}