Saving and Loading UIImage iPhone Issue
===

I am having a huge headache working out whats wrong with my app. I am trying to save and load UIImages, simple right? Seems not so.

I have a class with these methods to save, load and delete an image with a unique string. Just how I like it, nice and simple. Here is the class:

**imageSavedLoad.h:**

    #import <Foundation/Foundation.h>
    
    @interface imageSaveLoad : NSObject
    
    - (void)saveImage:(UIImage*)image forKey:(NSString*)imageName;
    - (void)removeImage:(NSString*)fileName;
    - (UIImage*)loadImage:(NSString*)imageName;
    
    @end

**imageSaveLoad.m:**

    #import "imageSaveLoad.h"
    
    
    @implementation imageSaveLoad
    
    //saving an image
    - (void)saveImage:(UIImage*)image forKey:(NSString*)imageName
    {
        NSData *imageData = UIImagePNGRepresentation(image);
        NSFileManager *fileManager = [NSFileManager defaultManager];
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageName]];
        [fileManager createFileAtPath:fullPath contents:imageData attributes:nil];
        NSLog(@"image saved");
    }
    
    //removing an image
    - (void)removeImage:(NSString*)fileName
    {
        NSFileManager *fileManager = [NSFileManager defaultManager];
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", fileName]];
        [fileManager removeItemAtPath: fullPath error:NULL];
        NSLog(@"image removed");
    }
    
    //loading an image
    - (UIImage*)loadImage:(NSString*)imageName
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageName]];
        return [UIImage imageWithContentsOfFile:fullPath];
    }
    
    @end

Where I want to save, load or delete an image I import the class: `#import "imageSaveLoad.h"`

Then I create an instance of it and call the required methods (here I save):

    imageSaveLoad *imgSL = [[imageSaveLoad alloc] init];
    [imgSL saveImage:photoImgView.image forKey:@"yourPhoto"];

Then in another view/class where I want to retrieve the image:

    imageSaveLoad *imgSL = [[imageSaveLoad alloc] init];
    yourImgView.image = [imgSL loadImage:@"yourPhoto"];

But `yourImgView` displays nothing, blank. 

So where am I going wrong? I have checked all `IBOutlet` connections and that all the code is being called. Is there a problem with the methods I am using?

Any help much appreciated, its driving me up the wall.