FROM : Jeremy Dronfield
DATE : Wed Dec 01 19:51:08 2004
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
DATE : Wed Dec 01 19:51:08 2004
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
| Related mails | Author | Date |
|---|---|---|
| Jeremy Dronfield | Dec 1, 19:51 | |
| Adam R. Maxwell | Dec 2, 06:10 | |
| Jeremy Dronfield | Dec 2, 12:27 |






Cocoa mail archive

