add utils class

This commit is contained in:
Bob Sun 2017-02-08 19:27:57 +08:00
parent 708a875d9d
commit 931e21008b
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 29 additions and 0 deletions

25
pass/Utils.swift Normal file
View file

@ -0,0 +1,25 @@
//
// Utils.swift
// pass
//
// Created by Mingshen Sun on 8/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import Foundation
class Utils {
static func removeFileIfExists(atPath path: String) {
let fm = FileManager.default
do {
if fm.fileExists(atPath: path) {
try fm.removeItem(atPath: path)
}
} catch {
print(error)
}
}
static func removeFileIfExists(at url: URL) {
removeFileIfExists(atPath: url.path)
}
}