Is there a way to open the Finder's "Get Info" window within my app for some path, programmatically?
There is another simple solution, you can see in the apple's "Photo Search" project.
Following is the code which you can use to show "Get Info" Window for single file as per the sample.
- (void)infoButtonAction:(NSOutlineView *)sender {
// Access the row that was clicked on and open that image
NSInteger row = [sender clickedRow];
SearchItem *item = [resultsOutlineView itemAtRow:row];
// Do a "reveal" in finder
if ([item filePathURL]) {
NSPasteboard *pboard = [NSPasteboard pasteboardWithUniqueName];
[pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
[pboard setString:[[item filePathURL] path] forType:NSStringPboardType];
NSPerformService(@"Finder/Show Info", pboard);
}
}
I have further modified the code as per my need to show the dialog for multiple files as follows:
NSPasteboard *pboard = [NSPasteboard pasteboardWithUniqueName];
[pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
NSMutableArray *fileList = [NSMutableArray new];
//Add as many as file's path in the fileList array
for(FileItem *item in fileItems) {
[fileList addObject:[[item.filePath filePathURL] path]];
}
[pboard setPropertyList:fileList forType:NSFilenamesPboardType];
NSPerformService(@"Finder/Show Info", pboard);
Hope, this will help, and FYI, this will work with sandboxed App in Lion and later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With