How do you access a file to use in unit tests? (Every time I have asked with more specific information I cannot get ANYONE to answer.)
+1
A:
What exactly are you trying to do? If you are trying to dump a data file and re-read it:
// To Dump:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"/MyDataFile"];
[NSKeyedArchiver archiveRootObject:mediaManager toFile:filePath];
// To Re-Load:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"/MyDataFile"];
myReciever = [[NSKeyedUnarchiver unarchiveObjectWithFile:filePath] retain];
Kenny
2010-04-22 21:10:28