NickName:doovers Ask DateTime:2016-11-17T05:00:32 UIImage(contentsOfFile:) returning nil despite file existing in caches directory This question already has answers here: Copyright Notice:Content Author:「doovers」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.Link to original article:https://stackoverflow.com/questions/40642217/uiimagecontentsoffile-returning-nil-despite-file-existing-in-caches-directory Answers Products recommended by Amazon More >>> SanDisk 128GB microSDXC-Card, Licensed for Nintendo-Switch - SDSQXAO-128G-GNCZN HUANUO Dual Monitor Stand - Adjustable Spring Monitor Desk Mount Swivel Vesa Bracket with C Clamp, Grommet Mounting Base for 13 to 27 Inch Computer Screens - Each Arm Holds 4.4 to 14.3lbs AMD Ryzen 5 5600X 6-core, 12-Thread Unlocked Desktop Processor with Wraith Stealth Cooler Timberland Men's 6-Inch Premium Waterproof Boot More about “UIImage(contentsOfFile:) returning nil despite file existing in caches directory” related questions UIImage set image withfile in caches directory I am getting nil image when i try to set image from local file path (Caches directory) file:///...... NSString* localImagePath=@"file:///Users/mac/Library/Application%20Support/iPhone%20Simulator/... Show Detail Memory Problems with UIImage(contentsOfFile) I have a Collection View where i load some Images from my documents directory: func reloadNotesFromStore() { { let fetchRequest = NSFetchRequest(entityName: "TaskDraw") let Show Detail UIImage using contentsOfFile I am using self.imageView.image = UIImage(named: "foo.png") to select and load images in an UIIMageView. I have the images in my app under the images.xcassets. The problem is that this particular... Show Detail Loading file from Directory to UIIMAGE doesnt work So i'm downloading an image using DownloadTask , and than save the image in the Cache Directory with name for my own uses : let fileManager = NSFileManager.defaultManager() let doc... Show Detail Not able to create files in caches directory I'm trying to set up a caches directory for use in my app, but the files are not being created for a reason unknown to me. What am I doing wrong? Here are the methods I'm using: In class Utilities... Show Detail UIImage imageNamed returning nil UIImage imageNamed returning nil in xcode 6 on iphone 6 simulator.. but perfectly works on xcode 5 code: UIImage *img=[UIImage imageNamed@"img@2x~ipad"]; Show Detail Getting asset catalog path for image using UIImage(contentsOfFile:) When you drag an image from the desktop into the asset catalog in Xcode, you can access that image in a project using: UIImage(named: "somePNG") But how do you access that image using UIImage( Show Detail UIImage returns nil but exists I have a problem in Swift. I try to load an image which is stored in the DocumentsDirectory but it returns nil. Here is the code: if NSFileManager.defaultManager().fileExistsAtPath(url!.path!) { ... Show Detail can't get UIImage's init(contentsOfFile:) to work I am trying to locate a file in a subdirectory of subdirectory of my bundle. I used this code to create an UIImage with init(contentsOfFile:). let resource = NSBundle.mainBundle().pathForResource(... Show Detail How can I use UIImage(contentsOfFile:String) with image data downloaded from the internet? I have an app which is loading a lot of image data from a web server. The data is being saved onto the ipad via: func saveParsedObject(objectToSave:AnyObject,dataCode:Int) { var path:S... Show Detail