journal
all ![]() | Rob is 20,118 days old today. |
Apr 2012 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
June 2012 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2011 jan feb mar apr may jun jul aug sep oct nov dec
2013 jan feb mar apr may jun jul aug sep oct nov dec |< << more >> >| |
Entries this day: seeking-simple-ios-class-to-return-appropriate-file-path-based-on-ios-version-and-storage-longevity seeking simple ios class to return appropriate file path based on ios version and storage longevity ##20:41 Wednesday 23 May 2012 My latest SE question: https://programmers.stackexchange.com/questions/149806/seeking-simple-ios-clas... In my first iPhone project, I've got this code essentially repeated in several places across my few classes: // taken from https://ipgames.wordpress.com/tutorials/writeread-data-to-plist-file/ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:filename]; Obviously I don't want to repeat this code all over the place. I think I should create a nice little class to return a full path given a filename and one of the four storage types ("Critical", "Cached", "Temporary" or "Offline") listed in Data Handling Categories Then I realized the class should handle different iOS versions appropriately, returning, for example, a path in the Cache for 5.0 and below, and a [do not back up] file in Documents for 5.0.1 and above. Then I realized someone has probably done it already, better than I could. Do you know of a class that will abstract the above logic into one line of code? permalinkprev day next day |