Use this when retrieving an image of an image selected from the gallery using imagepicker:
-(void)saveImageInDirectoryAndStoreInDatabase { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); NSString *documentsDir = [paths objectAtIndex:0]; NSString *imgFilePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",youruserName]; NSData *data = UIImagePNGRepresentation(youruserImage)
Similarly, when extracting the image, use documentDirectory + imageFile.png (which is obtained from the database by querying the username with its image file) to set pic user profile
Paresh navadiya
source share