0

iOS8.4 and Xcode6.4,
NOTE: database path:/Library/Developer/CoreSimulator/Devices/FD6CE853-5AE2-48DA-A9B1-E69A6BB4F9F8/data/Containers/Data/Application/BED214A4-65E1-4BD8-9908-29E07FD47EBA/Documents/DB/copybox.db
saving time file path:/Library/Developer/CoreSimulator/Devices/FD6CE853-5AE2-48DA-A9B1-E69A6BB4F9F8/data/Containers/Data/Application/BED214A4-65E1-4BD8-9908-29E07FD47EBA/Documents/Images/010521PMThursdayAug2015.png
I want to load images from Document Directory.i tried many ways as bellow.

NSString*path = [info valueForKey:@"copied_img_path"];
    path = [path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    path = [NSString stringWithFormat:@"file:/%@",path];//
    NSLog(@"\n##IMAGE PATH##:-%@\n",path);
//Tried with this
    [imageview setImageWithURL:[NSURL fileURLWithPath:path]];
//Tried with this
    NSURL* pathurl = [NSURL URLWithString:path];
    [imageview setImageURL:pathurl];
//Tried with this
    UIImage* image = [UIImage imageWithContentsOfFile:path];
    [imageview setImage: image];


but no success.
then i check file path when i save images in document directory. it is OK. but next time i run this code the current application folder disappears. so, in iOS8.3+ has any change in accessing document directory or i'm making any mistake. please let me know.
thanks in advance

Vatsal Shukla
  • 1,274
  • 12
  • 25

1 Answers1

1

You should never save the full path, the GUID in the path will change.

Just request the path to the document directory and add the relative file path to the image to this path.

rckoenes
  • 69,092
  • 8
  • 134
  • 166