0 Replies
      Latest reply on Oct 22, 2019 2:55 AM by SyamalaDutt
      SyamalaDutt Level 1 Level 1 (0 points)

        So when i run below code , i get Catalina User consent "Your App wants to access Documents folder"

        do {
                    //return [FileAttributeKey : Any]
                    let attr = try FileManager.default.attributesOfItem(atPath: "/Users/catalina/Documents/Test.docx")
                    var fileSize = attr[FileAttributeKey.size] as! UInt64
                    //if you convert to NSDictionary, you can get file size old way as well.
                    let dict = attr as NSDictionary
                    fileSize = dict.fileSize()
                } catch {
                    print("Error: \(error)")

        Even when i click on Don't allow, still the API returns attributes and API never throws any error. How can i catch the exception here and redirect user to give permissions in System Preferences.