Fetch the Attributes of File in Swift

Photo by Viktor Talashuk on Unsplash

While working with files, we might come across a situations to fetch the created date of file or size of file. The attributes of a file can be fetched in following way:

‘self.startAccessingSecurityScopedResource’ allows us to access the file in the URL securely.

‘FileManager.default.attributesOfItem(atPath: self.path)’ gives attributes of file.

From attributes array, select a file attribute key and cast the value to appropriate data type

Thanks for Reading:))

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sai Durga Mahesh

Using Data Science to provide better solutions to real word problems