System service can't get multiple filenames from Finder
System service can't get multiple filenames from Finder
- Subject: System service can't get multiple filenames from Finder
- From: Jeremy Dronfield <email@hidden>
- Date: Wed, 1 Dec 2004 18:51:08 +0000
I'm working on a little System Service to automate certain file
operations on files selected in the Finder. I've built a prototype
service, got it registered and recognised, and all seems fine. The
problem is, I can't get the Finder to give me more than one filename at
a time. With one file selected, I can choose my service from the
Services menu, and it performs the desired method. But with more than
one file selected, my service menu item is greyed out. Can anyone give
me a clue as to what might be wrong here? Surely this can't be an
inherent limitation of Finder?
My service has NSSendTypes set to NSFilenamesPboardType, and no
NSReturnTypes (since it doesn't send anything back to the Finder), so:
<key>NSSendTypes</key>
<array>
<string>NSFilenamesPboardType</string>
</array>
The method called when the service is registered as:
<key>NSMessage</key>
<string>getTheseFiles</string>
and implemented as:
- (void)getTheseFiles:(NSPasteboard *)pboard
userData:(NSString *)userData
error:(NSString **)error
{
if ([pboard propertyListForType:NSFilenamesPboardType] != nil) {
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
id file;
NSEnumerator *fileEnum = [files objectEnumerator];
while (file = [fileEnum nextObject])
NSLog(@"file:%@", file);
return;
} else {
*error = @"No files selected";
}
return;
}
Regards,
Jeremy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden