I have about 60 images that I want to save in Core Data, 30 of which are avatars and have the avt_filename_00X.png prefix, and 30 of them are smaller and have a different prefix.
Instead of storing all the images as a BLOB in Core Data / SQLite, I want to save the paths for each image found (just like you saved the image paths for the MySQL database).
However, I am not sure how to capture the image path found in the NSBundle.
I can get the path to NSDocumentDirectory through:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSFileManager *fileManager = [NSFileManager defaultManager]; [fileManager fileExistsAtPath:documentsDirectory]; NSLog(@"documentsDirectory = %@", documentsDirectory);
And I can load the image and add it to the array.
if (qty == 0) { //NSLog(@"fileToLoad = %@", fileToLoad); UIImage *img = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileToLoad ofType:fileExt]]; [self.avtList addObject:img]; [img release]; } else { // load multiple image into an array // not coded yet }
But I am not sure of the following:
The idea would be to get all the images stored in the array and then output them to Core Data / SQLite later.
objective-c image path core-data nsbundle
zardon
source share