title: How to know if user can read the content of a directory in swift
body: <p>In order to avoid a known bug, I need to kwnow before enumerating a directory, if the user can read it.</p>
  
  <p>How can I do that in swift (most recent version, using Xcode and MAC OS most recent version)?</p>
  
  <p><strong>More info:</strong>
  Trying to enumerate a directory in swift can lead to an application crash if the user can't access it. There is no way to catch an error to prevent the crash but it only happen if the user can't access the directory. So, knowing beforehand if the directory can be read (thus enumerated) would help in preventing the crash.</p>
  
  <p><strong>Cashable code:</strong></p>
  
  <p>There is this example : <a href="https://bugs.swift.org/browse/SR-2872" rel="nofollow noreferrer">https://bugs.swift.org/browse/SR-2872</a> reported by <strong>Timothy Wood</strong></p>
  
  <p>And this example : <a href="http://prod.lists.apple.com/archives/cocoa-dev/2016/Oct/msg00166.html" rel="nofollow noreferrer">http://prod.lists.apple.com/archives/cocoa-dev/2016/Oct/msg00166.html</a> reported by <strong>Jean Suisse</strong></p>