macOS Services

I know @tempelorg knows how to do this since Find Any File does it

I’ve got the skeleton of an app sketched out that provides a service but when it some to actually performing the service I’m a little confused

I had followed along with Providing a Service

which is one of the VERY few documents I could find

But I want a service like FAF’s : Search Folders and what I’m unclear on is what data the method providing the service gets
Its obviously NOT whatever the Apple document suggests - since the code

 
     if (![pboard canReadObjectForClasses:classes options:options]) {
          *error = NSLocalizedString(@"Error: couldn't encrypt text.",
               @"pboard couldn't give string.");
          return;
     }

always fails to find anything on the pasteboard(s)

Any hints ?

Here’s my code:

- (BOOL)findByName:(NSPasteboard*)pb userData:(NSString*)userData error:(NSError* __autoreleasing *)errorOut
{
	NSString *searchText = [pb stringForType:NSStringPboardType];
	…
	return YES;
}

And the Info.plist for this:

<key>NSServices</key>
<array>
	<dict>
		<key>NSMenuItem</key>
		<dict>
			<key>default</key>
			<string>FAF: Find Name</string>
		</dict>
		<key>NSMessage</key>
		<string>findByName</string>
		<key>NSPortName</key>
		<string>Find Any File</string>
		<key>NSRequiredContext</key>
		<dict/>
		<key>NSReturnTypes</key>
		<array/>
		<key>NSSendTypes</key>
		<array>
			<string>NSStringPboardType</string>
		</array>
	</dict>
</array>
2 Likes

MBS comes also with a Xojo project for services.

Thanks !