iOS中NSSearchPathForDirectoriesInDomains函数参数 NSDocumentDirectory, NSDocumentationDirectory, NSDownloadsDirectory的意义
刚在写程序的时候把所有参数都测试了下,这样自己可以记住,下面是测试结果:
NSDocumentDirectory
-(NSString *) dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory=[paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:@"data.plisg"]; }
return value:
NSDocumentationDirectory
-(NSString *) dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory , NSUserDomainMask, YES); NSString *documentsDirectory=[paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:@"data.plisg" ]; }
return value:
path:/Users/admin/Library/Application Support/iPhone Simulator/5.0/Applications/4BC5DA66-B3CA-4056-927B-999BC4DBF3CE/Library/Documentation/data.plist
NSDownloadsDirectory
-(NSString *) dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES); NSString *documentsDirectory=[paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:@"data.plisg" ]; }
return value:
path:/Users/admin/Library/Application Support/iPhone Simulator/5.0/Applications/4BC5DA66-B3CA-4056-927B-999BC4DBF3CE/Downloads/data.plisg