NICopyDBToSandBox
NICopyDBToSandBox (0.0.2) NICopyDBToSandBox: 拷贝 DB 文件到沙盒中及其他涉及沙盒 Documents 文件夹内/产品(Ant.ipa 包里面)文件夹内 fileName 操作
- pod 'NICopyDBToSandBox', '~> 0.0.2'
- 主页: https://nixinsheng.github.io/
- 来源: https://github.com/wvqusrtg/NICopyDBToSandBox.git
- 版本: 0.0.2 [master 仓库]
#####开源库包含方法列表:
/** 拷贝 DB 模板用,不仅仅是拷贝 AS.sqlite 库文件,还可以拷贝其他资源文件 DATA_BASE_FILE_NAME @param DBName 数据库名称 @return 是否拷贝成功
*/
- +(BOOL)copyDBToDocumentsWithDBName:(NSString*)DBName;
/** 获取 Documents 路径 @return Documents 路径
*/
- +(NSString*)getDocumentsPath;
/** 获取 Documents 路径下所有文件 @return 获取到的 Documents 路径下所有文件 NSArray 列表
*/
- +(NSArray*)getAllFileNamesArrayFromDocuments;
/** 获得文件在沙盒 documents 文件下详细路径,名称方便记忆 @param filename 文件名称要已知 @return 文件在沙盒 documents 文件下详细路径
*/
- +(NSString*)getFileFullPathFromDocuments:(NSString*)filename;
/** 获取文件在工程中(产品)(Ant.ipa 包里面)的详细路径 @param filename 文件名称 @return 文件在工程中(Ant.ipa 包里面)的详细路径
*/
- +(NSString*)getFileFullPathFromProduct:(NSString*)filename;
/** 把 NSDictionary/NSMutableArray 写入到沙盒 Documents 文件夹内 fileName (eg: UserInfo.plist 文件不存在则新建文件) 里 @param dic 目标待写入字典 @param fileName 目标写入文件名 @return 是否写入成功
*/
- +(BOOL)saveNSDictionaryForDocuments:(NSDictionary*)dic WithFileName:(NSString*)fileName;
- +(BOOL)saveNSMutableArrayForDocuments:(NSMutableArray*)dic WithFileName:(NSString*)fileName;
/** 把 NSDictionary/NSMutableArray 写入到产品(Ant.ipa 包里面)文件夹内 fileName (eg: UserInfo.plist 文件不存在则新建文件) 里 @param dic 目标待写入字典 @param fileName 目标写入文件名 @return 是否写入成功
*/
- +(BOOL)saveNSDictionaryForProduct:(NSDictionary*)dic WithFileName:(NSString*)fileName;
- +(BOOL)saveNSMutableArrayForProduct:(NSMutableArray*)dic WithFileName:(NSString*)fileName;
/** 从沙盒 Documents 文件夹内/产品(Ant.ipa 包里面)文件夹内 fileName 中加载 plist 数据 NSDictionary/NSMutableArray @param fileName 文件名 @return 加载来的数据
*/
- +(NSDictionary*)loadNSDictionaryFromDocumentsWithFileName:(NSString*)fileName;
- +(NSDictionary*)loadNSDictionaryFromProductWithFileName:(NSString*)fileName;
- +(NSArray*)loadNSArrayFromDocumentsWithFileName:(NSString*)fileName;
- +(NSArray*)loadNSArrayFromProductWithFileName:(NSString*)fileName;
判断沙盒 Documents 文件夹内/产品(Ant.ipa 包里面)文件夹内 文件是否存在
- +(BOOL) fileIsExistsFromDocumentsWithFileName:(NSString*)fileName;
- +(BOOL) fileIsExistsFromProductWithFileName:(NSString*)fileName;
2、NICopyDBToSandBox (0.0.1) NICopyDBToSandBox: 拷贝 DB 文件到沙盒里的 Document 目录下
- pod 'NICopyDBToSandBox', '~> 0.0.1'
- 主页: https://nixinsheng.github.io/
- 来源: https://github.com/wvqusrtg/NICopyDBToSandBox.git
- 版本: 0.0.1 [master 仓库]
#####沙盒目录结构-每个 APP 的沙盒下面都有相似的目录结构,如图(苹果官方文档)
4、二、获取各种文件目录的路径
获取目录路径的方法:
// 获取沙盒主目录路径 NSString *homeDir = NSHomeDirectory();
// 获取 Documents 目录路径
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
// 获取 Library 的目录路径
NSString *libDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
// 获取 Caches 目录路径
NSString *cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
// 获取tmp目录路径
NSString *tmpDir = NSTemporaryDirectory();
获取应用程序程序包中资源文件路径的方法:
NSLog(@"%@",[[NSBundle mainBundle] bundlePath]);
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"apple" ofType:@"png"];
UIImage *appleImage = [[UIImage alloc] initWithContentsOfFile:imagePath];
####有问题或建议请联系:
QQ:1911398892
微信号:wvqusrtg