1 Reply
      Latest reply on Oct 22, 2019 3:50 AM by Claude31
      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 = att
        
        r[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.

        • Re: How to catch Catalina Don't allow exception
          Claude31 Level 8 Level 8 (6,865 points)

          Could you add a log just after the assignment of fileSize line 5 ?

           

          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)")
                  }