對於下面的代碼:
- (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'
您期望有多少物品 回? – Eric
我希望獲得我在Finder中選擇的項目數。 它的工作原理,但如果我選擇了超過10個項目,它只是說我已經選擇了10個,而不是更多。似乎是蘋果的某種限制。我不知道。 –
我正在使用'selectedItemURLs',可以生成甚至1000個項目的選擇。請顯示你的代碼,你必須做一些其他的錯誤。 – Mugen