2

NSOpenPanel を使用してアプリケーションにフォルダーを設定していますが、これをフォルダー「file://localhost/Users/juan/」のパスとして取得しています

これは私のコードです:

    NSOpenPanel * setDirectory = [NSOpenPanel openPanel];
    setDirectory.canChooseFiles=NO;
    setDirectory.canCreateDirectories=YES;
    setDirectory.canChooseDirectories=YES;
    setDirectory.directoryURL=_path;
    [setDirectory beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
        NSLog(@" results %ld", result);
        if (NSFileHandlingPanelCancelButton){
            NSLog(@"cancel");

        }
        if (NSFileHandlingPanelOKButton) {

            self.path = [[setDirectory URLs] objectAtIndex:0];

        }

    }];
}

私の質問は、file://localhost なしで「/Users/juan/Desktop/」などの絶対パスを取得するために、どのように、または何をする必要があるかです。

私は本当にポインタに感謝します。

4

2 に答える 2

4

これを行うpathには、オブジェクトのメソッドを呼び出しNSURLます。

于 2012-12-21T03:17:59.953 に答える