NSWorkspace openFile withApplication does not work with spaces in the file name

when using this

[ [NSWorkspace sharedWorkspace] openFile:fileName withApplication:appName]; 

and file_name contains spaces

another application complains that it cannot open the file name

I have no source for another application

but when I run the same application with NSTask , it can correctly read the full path to the file

I tried to surround the file path with quotes, but that did not help

+4
source share
1 answer

This is definitely not an NSWorkspace issue. You do not need any shell leaks. In any case, NSWorkspace does not launch another application through the shell. And I can open in Safari an html file whose name contains a space using NSWorkspace .

So the problem is in another application. What kind of app is this? If you do not have a source, there is nothing you can do about it except to complain to the creator / author of this program.

0
source

Source: https://habr.com/ru/post/1338944/


All Articles