ios - Best way to persist an array of images? -


I'm looking for a way to continue images for an array (or similar) after the app closes Can be reached by a relaunched - it is also necessary to sort images by date. Currently I am able to store images in the NSD document directory of the app with the following code: < Pre> - (NSString *) currentDateandTime {NSDate * today = [NSDate date]; NSDateFormatter * dateFormat = [[NSDateFormatter alloc] init]; [DateFormat setDateFormat: @ "MMddyyyy_HHmmss"]; NSString * dateString = [dateFormat stringFromDate: today]; Return date string; } - (zero) Save image document {NSDTa * imageData = UIIMPNGR presentation (image); NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, yes); NSString * document directory = [path item overindexx: 0]; NSString * date = [auto current date time]; NSString * imagePath = [document directory stringbapping path comparison: [NSString stringWithFormat: @ "% @ _ image.png", date]]; }

This means that I have images, where the date / time is in the file names of the image. Thanks for reading what is the best way to archive these images in the array or the dictionary and arrange them according to date / time!

I save file names and stars in a plist file that is an array of the format of the dictionary: @ {@ "filename": image file name, @ "Date": imageDate} .

When you load that code in NSArray , you can easily sort it by specifying your own comparison method, eg:

  NSArray * filenames = [[NSArray alloc] initWithContentsOfFile: filePath]; NSArray * Sorted filename = [filename sortedAreuzUzingcomputer: ^ NscimperionRisalt (NSODF * dict1, nspection * dict 2) {NSDT * date1 = dec 1 [@ "date"]; NSDate * date2 = dict2 [@ "date"]; Return [compare date1: date2]; }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -