NSPerformService(@"Copy Selected Text", pboard);
- (void)copyText:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error {
NSString *copiedText = [pboard stringForType:NSStringPboardType];
NSLog('copied text %@', copiedText);
}
The copyText:userData:error: invoked successfully but the copiedText is empty which shouldn't. I do have select some text before I call NSPerformService.
If I invoke my service by select the Service menu, it works properly.
I assume that calling NSPerformService didn't write the selection text into the generalPasteboard.