-(NSURL*)applicationDocumentsDirectory{ return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];}-(NSString*)applicationDocumentsDirectoryPath{ return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];}
区别如下:
NSLog(@"%@",storeURL);NSLog(@"%@",storePath);NSLog(@"%@",[storeURL absoluteString]);
结果分别为
file://localhost/Users/apple/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/A2187B83-2937-46AC-9829-D87B4D292E7C/Documents/
/Users/apple/Library/Application Support/iPhone Simulator/6.0/Applications/A2187B83-2937-46AC-9829-D87B4D292E7C/Documents/
file://localhost/Users/apple/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/A2187B83-2937-46AC-9829-D87B4D292E7C/Documents/
因此若需要使用方法
NSFileManager* fileManager = [NSFileManager defaultManager];[fileManager fileExistsAtPath:storePath];
必须使用applicationDocumentsDirectoryPath,而不能使用 [URL absoluteString];