我在打開其中有空格的目錄時遇到問題。我的代碼如下所示:帶空格的OSX目錄
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseDirectories:YES];
if ([openDlg runModal] == NSOKButton)
{
NSArray* files = [openDlg URLs];
NSString* directoryName = [[files objectAtIndex:0] absoluteString];
directoryURL = [files objectAtIndex:0];
NSLog(@"Directory Name: %@", directoryName);
NSArray *directoryArray = [directoryName componentsSeparatedByString:@"/"];
NSString* currentDirectory = [directoryArray objectAtIndex:(directoryArray.count- 2)];
[directoryBox setTitle:currentDirectory];
}
當我選擇用空格文件沒有顯示在表中的NSLog輸出看起來像這樣一個目錄名:
目錄名稱:
file://localhost/Users/Rich/Software%20Bisque/
有沒有想法?
這是更正確的方向或它應該工作嗎?不幸的是,我仍然看到目錄名稱:file:// localhost/Users/Rich/Software%20Bisque /並且directoryBox標題是設置爲Rich。: -/ – Marquisk2
得到它的工作!謝謝! – Marquisk2