iOS获取文件路径

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#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