Tuesday, 10 December 2013

How to check document directory file your image is there or not

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
    NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:@"/progress/before.png"];

  if (![[NSFileManager defaultManager] fileExistsAtPath:imagePath])
    {
       //file not exits in Document Directories
        imageviewname.image = [UIImage imageNamed:@"add_photo_block_hires.png"];
    }
    else
    {
        //file exist in Document Directories
         imageviewname.image =[UIImage imageWithContentsOfFile:imagePath1];

    }

No comments:

Post a Comment