#import <Foundation/Foundation.h>
@interface NSString (Path)
- (NSString *)appendDocument;
- (NSString *)appendCache;
- (NSString *)appendTmp;
@end
#import "NSString+Path.h"
@implementation NSString (Path)
- (NSString *)appendDocument {
NSString *root = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
return [root stringByAppendingPathComponent:[self lastPathComponent]];
}
- (NSString *)appendCache {
NSString *root = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)lastObject];
return [root stringByAppendingPathComponent:[self lastPathComponent]];
}
- (NSString *)appendTmp {
NSString *root = NSTemporaryDirectory();
return [root stringByAppendingPathComponent:[self lastPathComponent]];
}
@end
工具类:快速拼接文件路径( NSString 分类)
最新推荐文章于 2023-03-11 19:57:27 发布