環境
- X-code 9.4
- Swift4.1
コード
覚え書き程度ですが。
// パスを取得
let libraryPath = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true).first as String?
let cookiesPath = libraryPath?.appending("/Cookies")
let webKitPath = libraryPath?.appending("/WebKit")
let cachesPath = libraryPath?.appending("/Caches")
print("------libraryPath:" + libraryPath! + "------")
print("------cookiesPath:" + cookiesPath! + "------")
print("------webKitPath:" + webKitPath! + "------")
// ファイルの削除
do {
try FileManager.default.removeItem(atPath: cachesPath!)
try FileManager.default.removeItem(atPath: cookiesPath!)
try FileManager.default.removeItem(atPath: webKitPath!)
} catch {
// エラー処理
}
"/Cookies"
とか、文字列なのが、なんとなく、ただなんとなくいけ好かないけれど、
エラーになることなく実行できました。