通过 NSFileManager 在 applescript 中创建随机临时目录

问题描述 投票:0回答:0

我正在尝试使用 NSFileManager。我知道我可以在没有 NSFileManager 的情况下做到这一点,这超出了这个问题的范围

use framework "Foundation"

set temporaryDirectory to URLForDirectory_inDomain_appropriateForURL_create_error_(NSItemReplacementDirectory of current application, NSUserDomainMask of current application, (fileURLWithPath_isDirectory_("/", true) of class "NSURL" of current application), true, nil) of defaultManager of class "NSFileManager" of current application

以下是重新格式化后的版本:

set temporaryDirectory
    to URLForDirectory_inDomain_appropriateForURL_create_error_(
        NSItemReplacementDirectory of current application,
        NSUserDomainMask of current application,
        (fileURLWithPath_isDirectory_("/", true) of class "NSURL" of current application),
        true,
        nil
    )
        of defaultManager of class "NSFileManager" of current application

这是我得到的错误

error "The variable nil is not defined." number -2753 from "nil"
objective-c applescript objective-c-runtime applescript-objc sirishortcuts
© www.soinside.com 2019 - 2024. All rights reserved.