how to get the path of selected PDF/doc from file manager in ios swift programmatically
// Get the document directory url
let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
do {
// Get the directory contents urls (including subfolders urls)
let directoryContents = try FileManager.default.contentsOfDirectory(at: documentsUrl, includingPropertiesForKeys: nil)
print(directoryContents)
// if you want to filter the directory contents you can do like this:
let mp3Files = directoryContents.filter{ $0.pathExtension == "mp3" }
print("mp3 urls:",mp3Files)
let mp3FileNames = mp3Files.map{ $0.deletingPathExtension().lastPathComponent }
print("mp3 list:", mp3FileNames)
} catch {
print(error)
}
Also in Swift:
- swift thread.sleep
- get local currency iap swift
- swift open web page
- disable button in swiftui
- use alamofire to login in swift 5
- how to style textfield swiftui
- how to add two right bar button item xcode
- swift create a method who can return result or throw an error
- swift credit card validate
- how to compose a custom scene in swiftui
- textchange in textview swift
- where to save audio asset swift
- swift convert base64 string to data
- swift increase int value
- swift change navigation bar title
- swift check dictionary has key
- sqlite in swift
- swift create uinavigationcontroller programmatically
- swift play audio file
- how to make a quiz swift stack overflow
- swift set image size
- disable dark mode swift
- special symbol ios swift
- how to delete from list tvos swiftui coredata