0
I downloaded an image and stored it on disk. After downloading the class inserts the image path into the core data, this string:
@"/Users/Tiago/Library/Developer/CoreSimulator/Devices/3E103B07-E48E-4740-911C-ECD24E0C3A3F/data/Containers/Data/Application/D17A1BA1-7096-49F9-BDAD-9587B2780715/Documents/54bf3ebf657f6f2c04a81b0b.jpg
"
But when loading this image into a Uiimage it is started with nil, as shown in the code below:
// Implementação de uma UITableView.
...
NSManagedObject *device = [dadosRetornadosDoCoreData objectAtIndex:indexPath.row];
...
NSString* stringPath = [device valueForKey:@"imagempath"];
UIImage* imageNew = [[UIImage alloc]initWithContentsOfFile:stringPath];
[cell.imagemProduto setImage:imageNew];
return cell;
I added an image to the project, and uploaded it as the code below:
UIImage* imageNew = [[UIImage imageNamed:@"cloud.png"];
And charged normally.
Detail: the String that leads to the image is coming from the Core Data storage. I don’t know if this can affect the interpretation of the String.
Not always the directory
Documents
will be in the same location, can change in an app update, for example. Ideally you save only the file name and then upload the image by mounting all the added name path.– Paulo Rodrigues
Thanks, I saw this recommendation in another post. How can I locate the folder? type as I tell the app to search for the file with the image name?
– Tiago Amaral