I am trying to take an image and place that image to imageView, I am able to do this. But I am not able to save this to device, I want my photo to be saved in my application folder and want to access it from another view.
studentImage is my UIImageView element where I am able to set the image taken from camera.
Here is the code I am working with :
NSString* format = @".png";
NSString* imagename = [NSString stringWithFormat:@"%@%@",nickname,format];
UIImage *img = [self.studentImage image];
NSData *pngData = UIImagePNGRepresentation(img);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:imagename];
[pngData writeToFile:filePath atomically:YES];
This statement is returning null : [pngData writeToFile:filePath atomically:YES];
It would be great, if some one can tell me how to access that image from another view.