//explore the files in directory
- (void)viewDidLoad
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"Documents directory: %@", [fileManager contentsOfDirectoryAtPath:documentDirectory error:nil]);
}
// determine the file exists in the directory
-(NSString *)dataFilePath
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
return [documentDirectory stringByAppendingPathComponent:data.plist];
}
- (void)viewDidLoad
{
NSString *filePath = [self dataFilePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath])
{
NSMutableArray *database = [[NSMutableArray alloc] initWithContentsOfFile:filePath];
other code...
}
[super viewDidLoad];
}
No comments:
Post a Comment