#import "NSString+WJ.h" @implementation NSString (WJ) - (instancetype)cacheDir { //1.获取Caches目录 NSString *path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; //2.生成绝对路径 return [path stringByAppendingPathComponent:[self lastPathComponent]]; } -(instancetype)docDir { NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) lastObject]; return [path stringByAppendingPathComponent:[self lastPathComponent]]; } - (instancetype)tmpDir { NSString *path = NSTemporaryDirectory(); return [path stringByAppendingPathComponent:[self lastPathComponent]]; } @end
时间: 2024-10-18 09:48:53