In xcode, I have create a folder called IMAGES and copied all of the images I will be using into that folder.
I am updating a table using the following code to insert the image:
NSString *picName = [NSString stringWithFormat:@"%@.jpg", [[theemplyees objectAtIndex:indexPath.row] valueForKey:@"EmpNo"]]; cell.empPicture.image = [UIImage imageNamed:picName];
Note the no location needing supplied. What I want to do is, if a users picture does not exist in the directly, then set the image to a default image. Such as:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; //Set image NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:picName]; //Check if the image exists at a given path BOOL imageExists = [[NSFileManager defaultManager] fileExistsAtPath:imagePath]; //If the image doesn't exists download it. if (!imageExists) { picName = @"nopicture.jpg"; }
The problem is, using the above, it ALWAYS says the files don't exist. NONE! Grrr So am i placing the files in the wrong location? I attempted to create a directory called Resources and place them there but still didn;t work.
Any help is greatly appreciated. Thanks in advance for any and all help.
Geo...