這適用於10.7,但不適用於10.8。我如何才能在山獅工作?在Finder中顯示不在10.8中工作
-(IBAction)showTargetInFinder:(id)sender
{
NSString *linkPath = [targetField stringValue];
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[ws selectFile:linkPath inFileViewerRootedAtPath:nil];
}
你應該和佩德羅維埃拉的解決方案去,因爲網址,而不是路徑是一般情況下,但另一件嘗試(如果只是爲了好奇),將使用基於路徑的方法,用'@「」'作爲文件查看器根目錄,而不是'nil'。 [文檔的解釋](http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWorkspace/selectFile: inFileViewerRootedAtPath :)比較陳舊,但要點是'@「」'是更有用的根值。 –