あなたはNSWorkspaceでゴミ箱にものを置くことができる、しかし、ゴミ箱を削除するなしなしプログラムのための一種でありますAPI。だからあなたの最善の策はScriptBridgeを使うことです。
ビルドターゲットにScriptingBridge.framework
を追加し、使用してファインダー用のヘッダファイルを生成します。そして、あなたがごみ箱を空にするを促すためにファインダーを依頼することができ
sdef /System/Library/CoreServices/Finder.app/ | sdp -fh --basename Finder
を:
#import "Finder.h"
FinderApplication *finder = [SBApplication applicationWithBundleIdentifier:@"com.apple.Finder"];
// activate finder
[finder activate];
// wait a moment (activate is not instant), then present alert message
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[finder emptySecurity:security];
});
を参照してください。詳細はScripting Bridge documentationをご覧ください。
Xcode 7.3から、Swiftでこれを試みると、Finder.hで定義されたクラスを見つけようとしてリンカエラーが発生します。したがって、Objective-Cラッパーを作成する必要があります。
なぜこれを行う必要がありますか?ごみ箱はユーザーの領域であり、あなたのアプリは本当にそれを乱すべきではありません。 –