我正在使用NSAppleScript从我的应用程序中运行applescript。我的问题是我有一个我想要转换为字符串的NSURL。当我转换它时,我得到:path / to / my / file,但applescript需要path:to:my:file。如何将NSURL转换为此格式?感谢。
答案 0 :(得分:4)
您可能会发现这很有用,它会将pathString转换为HFS样式路径(带冒号):
NSString* pathString = [@"~/Desktop/Home.m4v" stringByExpandingTildeInPath];
NSURL* theFileURL = [NSURL fileURLWithPath:pathString];
NSString* path = [(NSString*)CFURLCopyFileSystemPath((CFURLRef)theFileURL, kCFURLHFSPathStyle) autorelease];
NSLog(@"path= %@",path);
答案 1 :(得分:3)
而不是
file "foo:bar:baz"
使用
POSIX file "foo/bar/baz"