对于以下代码:
- (NSMenu *)menuForMenuKind:(FIMenuKind)whichMenu
{
NSArray *selectedPaths = [self getSelectedItems];
// ...
return ...
}
- (NSArray *)getSelectedItems
{
NSMutableArray *selectedItems = [[NSMutableArray alloc] init];
for (NSURL *selectedItemURL in [[FIFinderSyncController defaultController] selectedItemURLs]) {
[selectedItems addObject:selectedItemURL.path];
NSLog(@"FinderSync selected item at path '%@'", selectedItemURL.path);
}
return selectedItems;
}
对于以下目录:
选择目录中的所有文件并打开上下文菜单时,我得到以下输出:
11/11/15 7:52:24.432 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/1.txt'
11/11/15 7:52:24.432 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/2.txt'
11/11/15 7:52:24.432 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/3.txt'
11/11/15 7:52:24.432 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/4.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/5.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/6.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/7.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/8.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/9.txt'
11/11/15 7:52:24.434 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/10.txt'
11/11/15 7:52:24.434 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/11.txt'