如何检查 ApplescriptObjc 中是否存在目录
How to check if a directory exists in ApplescriptObjc
我知道在 AppleScript 中如何检查文件夹是否存在的经典方法,但对我不起作用,即使我使用错误检测方法也不起作用,我在网上找到了 Object- C方法fileExistsAtPath但也不知道怎么实现,我也raid了,没办法,有知道解决办法的请帮忙
我的代码现在看起来像这样
on CheckExistence(FileOrFolderToCheckString)
try
alias FileOrFolderToCheckString
return true
on error
return false
end try
end CheckExistence
谢谢
AppleScriptObjC 等价物是
use framework "Foundation"
on CheckExistence(FileOrFolderToCheckString)
set FileOrFolderToCheckPOSIXPath to POSIX path of FileOrFolderToCheckString
return (current application's NSFileManager's defaultManager()'s fileExistsAtPath: FileOrFolderToCheckPOSIXPath) as boolean
end CheckExistence
我知道在 AppleScript 中如何检查文件夹是否存在的经典方法,但对我不起作用,即使我使用错误检测方法也不起作用,我在网上找到了 Object- C方法fileExistsAtPath但也不知道怎么实现,我也raid了,没办法,有知道解决办法的请帮忙
我的代码现在看起来像这样
on CheckExistence(FileOrFolderToCheckString)
try
alias FileOrFolderToCheckString
return true
on error
return false
end try
end CheckExistence
谢谢
AppleScriptObjC 等价物是
use framework "Foundation"
on CheckExistence(FileOrFolderToCheckString)
set FileOrFolderToCheckPOSIXPath to POSIX path of FileOrFolderToCheckString
return (current application's NSFileManager's defaultManager()'s fileExistsAtPath: FileOrFolderToCheckPOSIXPath) as boolean
end CheckExistence