user3352739 user3352739 - 4 months ago 38
iOS Question

Nsapplescript open file

I have the following code:

NSAppleScript* playPause = [[NSAppleScript alloc] initWithSource:
@"tell application \"Xcode\"to activate \n to open POSIX file \"beetSapper.xcodeproj""\n"
@"end tell"];

[playPause executeAndReturnError:NULL];

However it is not opening the file "beetSapper" I guess the way I am writing the string is not working. Can somebody show how to write this command properly? Thanks


There are too many tos in the code.

Since Xcode accepts also POSIX paths you can write

tell application "Xcode"
    open "/Users/myUser/Documents/beetSapper.xcodeproj/"
end tell

The "stringyfied" equivalent is

"tell application \"Xcode\"\n activate\n open \"/Users/myUser/Documents/beetSapper.xcodeproj/\"\n end tell"

Be aware that you have to specify the full path to the project file starting with a slash.