1、在Info.pList中为服务创建了一个条目
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>创建文本</string>
</dict>
<key>NSKeyEquivalent</key>
<dict>
<key>default</key>
<string>W</string>
</dict>
<key>NSMessage</key>
<string>openWPS</string>
<key>NSPortName</key>
<string>QLMacTools</string>
<key>NSRequiredContext</key>
<dict/>
<key>NSReturnTypes</key>
<array/>
<key>NSSendTypes</key>
<array>
<string>NSFilenamesPboardType</string>
</array>
<key>NSUserData</key>
<string></string>
</dict>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>转大写</string>
</dict>
<key>NSMessage</key>
<string>upperCaseText</string>
<key>NSPortName</key>
<string>QLMacTools</string>
<key>NSRequiredContext</key>
<dict>
<key>NSServiceCategory</key>
<string>public.text</string>
</dict>
<key>NSReturnTypes</key>
<array>
<string>NSStringPboardType</string>
</array>
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
</array>
<key>NSUserData</key>
<string></string>
</dict>
</array>
2、实现功能
3、注册快捷服务
[NSApp setServicesProvider:[QLServiceFunManager new]];