I have checked many questions available on SO such as this & this, related to these errors but let me tell you my scenario.
I am loading images on a view & after clicking assets in collection view 18 times my code returns this error. I am not doing anything complex I am just adding the same asset which is been clicked on a view above that asset.
Information: I am creating assets & saving them in documents directory & fetching them from there only.
Below is my code where error is coming:
let data = try Data(contentsOf: URL(fileURLWithPath: (contentsOfFile: (userInfo[kPath] as! String))), options: .uncached)
I am trying to get imageData & then put it as image in image view but after few clicks the Try statement is returning following errors
"Too many open files"
I have also tried another way of loading image i.e.
UIImage(contentsOfFile: imageFilePath)!
but result is same.
Can anyone help me by guiding how to solve this error?