LoginSignup
2
0

More than 5 years have passed since last update.

fileURLからUTI(Uniform type identifier)を取得する

Posted at

すごく遅い。

func uti(url: URL) -> String? {

    return try? NSWorkspace.shared.type(ofFile: url.path)
}

少し早い。

func uti(url: URL) -> String? {

    guard let r = try? url.resourceValues(forKeys: [.typeIdentifierKey]) else {
        return nil
    }
    return r.typeIdentifier
}
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0