gpt4 book ai didi

objective-c - 将 NSURL 转换为 AppleScript 文件路径

转载 作者:行者123 更新时间:2023-12-03 16:25:21 24 4
gpt4 key购买 nike

我正在使用 NSAppleScript 从我的应用程序中运行 applescript。我的问题是我有一个 NSURL,我想将其转换为字符串。当我转换它时,我得到:path/to/my/file,但applescript需要path:to:my:file。如何将我的 NSURL 转换为这种格式?谢谢。

最佳答案

您可能会发现这很有用,它将路径字符串转换为 HFS 样式路径(带冒号):

NSString* pathString = [@"~/Desktop/Home.m4v" stringByExpandingTildeInPath];
NSURL* theFileURL = [NSURL fileURLWithPath:pathString];

NSString* path = [(NSString*)CFURLCopyFileSystemPath((CFURLRef)theFileURL, kCFURLHFSPathStyle) autorelease];

NSLog(@"path= %@",path);

关于objective-c - 将 NSURL 转换为 AppleScript 文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5520517/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com