saoudrizwan / Disk

Delightful framework for iOS to easily persist structs, images, and data
MIT License
3.08k stars 170 forks source link

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

Closed EthanSK closed 5 years ago

EthanSK commented 5 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 5 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