saoudrizwan / Disk

Easily persist structs, images, and data on iOS
MIT License
3.11k stars 172 forks source link

There is no way of retrieving all images in a folder and get their filename #47

Closed EthanSK closed 6 years ago

EthanSK commented 6 years ago

I can't seem to figure out how to get a dictionary of [String: UIImage] from a folder. I would assume this is a basic necessity, as you would need to be able to determine what images you actually saved!

Can someone tell me how to do this if I am missing it, or if it doesn't exist - can this be a feature request!

abdulhaq-e commented 6 years ago

Perhaps something like this will help you:


// Create a FileManager instance

let fileManager = NSFileManager.defaultManager()

// Get contents in directory: '.' (current one)

do {
    let files = try fileManager.contentsOfDirectoryAtPath(".")
    print(files)
}
catch let error as NSError {
    print("Ooops! Something went wrong: \(error)")
}

Copied from https://iswift.org/cookbook/get-directory-contents