Currently I am loading data from a previous session into my application using the code below. To guard against there being no previous data I am using a temp variable to check the return value before making my assignment. I am just posting here as this feels a bit clunky, is there a way to check a file exists on disk so I can check before continuing, or is what I have the way to go?
NSMutableArray *artistCollection;
NSMutableArray *artistCollection_LOAD;
artistCollection = [[NSMutableArray alloc] init];
artistCollection_LOAD = [NSKeyedUnarchiver unarchiveObjectWithFile:@"/data"];
if(artistCollection_LOAD != nil) artistCollection = artistCollection_LOAD;
else NSLog(@"(*) - Saved Data Not Found");
Prior to this I had (see below) but as you can imagine if NSKeyedUnarchiver did not find a file and returned "nil" it trashed my previously allocated array.
artistCollection = [[NSMutableArray alloc] init];
artistCollection = [NSKeyedUnarchiver unarchiveObjectWithFile:@"/data"];
gary