#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
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/aiops/3351.html