在iOS中加载已保存的图像

Ars*_*der 2 filesystems ios

我正在做的是保存从任何源(相机/库)加载的图像并将其保存到iOS中的文件系统.我所困的是如何使用该保存图像..我使用以下代码.它的工作是在Documents Folder中创建一个Test.jpg.但真的不知道如何访问这个Test.jpg.

NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
[UIImageJPEGRepresentation(selectedImage.image, 1.0) writeToFile:jpgPath atomically:YES];
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];  
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
Run Code Online (Sandbox Code Playgroud)

ber*_*ium 17

使用此方法:

let testImage = UIImage(contentsOfFile: filePath)

imageNamed 在应用程序的主包中查找具有指定名称的图像.