2014年6月6日 星期五
2014年6月4日 星期三
Objective-C locate file path sample
- (void)getDBpath { NSString *docsDir; NSArray *dirPaths; // Get the documents directory dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; // Build the path to the database file databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"mainframe.db"]]; //NSLog(@"DB full path name: %@", databasePath); NSFileManager *fileMgr = [NSFileManager defaultManager]; BOOL success = [fileMgr fileExistsAtPath:databasePath]; if (!success) { NSLog(@"Cannot locate database file '%@'.", databasePath); } }
訂閱:
文章 (Atom)