Let's say I create folders in the documents folders using this function below.
import UIKit
class ViewController: UIViewController {
var folders : [String] = ["Sayaka", "Amit",
"Kuni", "Suni"]
@IBAction func button(_ sender: Any) {
}
@IBOutlet weak var displayImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
createFolders()
}
func createFolders() {
for folder in self.folders{
let documentsPath1 = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])
let logsPath = documentsPath1.appendingPathComponent(folder)
print(logsPath!)
do {
try FileManager.default.createDirectory(atPath: logsPath!.path, withIntermediateDirectories: true, attributes: nil)
} catch let error as NSError {
print(error.debugDescription)
NSLog("Unable to create directory \(error.debugDescription)")
}
}
}
I have images in a folder in the left pane (not sure what the pane is called), named in accordance with the folder I want to copy said images to:
"Sayaka0", "Sayaka1" -> Sayaka folder
"Amit0" -> Amit folder
How would I go about doing this?
EDIT:
I found this function but It doesn't seem to be registered in the images in the Images folder under the Info.plist.
func moveImages(){
let fileManager = FileManager.default
let imagePath = Bundle.main.resourcePath! + "/Images"
print(imagePath)
do{
let imageNames = try fileManager.contentsOfDirectory(atPath: imagePath)
for image in imageNames{
print(image)}
}
catch{
print("Missing Images")}
}
Thank you.