I have two views in the 1st view that say A to save the image in the document directory when you click the save button and then the second view. B. I have two downloads of this image with a specific table cell. In the code below, I am trying to compare an image with a specific user email id. Email is common in both submissions. So I can distinguish a specific user from my email and in our table view cell we display our images in different ways. But I can’t do it ... How can this be achieved in Ios? AnyOne can help me with this .... My code for saving and uploading images to the document directory
enter code here
View A
-(void)saveImage: (UIImage*)image
{
if (image != nil)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [documentsDirectory stringByAppendingPathComponent:
@"iosImage.png" ];
NSString *fileName = [path stringByAppendingFormat:email];
NSLog(@"The result of Concatenate String =%@",fileName);
NSData* data = UIImagePNGRepresentation(image);
[data writeToFile:path atomically:YES];
NSLog(@"The Path of the directory %@",path);
}
}
View B
- (UIImage*)loadImage
{
NSLog(@"Email^^^^^^^^^%@",imgEmail);
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [documentsDirectory stringByAppendingPathComponent:
@"iosImage.png" ];
UIImage* image = [UIImage imageWithContentsOfFile:path];
NSLog(@"Documents directory: %@",[fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
return image;
}