문제

Does anyone know how to preselect a file in the NSOpenPanel dialog?

This has been asked several times before, but none of those questions were answered with a working solution. Setting nameFieldStringValue has no effect as the open dialog does not have a textfield for the user to type in a name. Setting the directoryURL only sets the current directory in the dialog.

도움이 되었습니까?

해결책

Try like this:-

NSOpenPanel *op=[NSOpenPanel openPanel];
[op setDirectoryURL:[NSURL URLWithString:@"file://localhost/Users/Home/Desktop/yourfile.sh/"]];
[op runModal];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top