61 lines
1.7 KiB
Objective-C
61 lines
1.7 KiB
Objective-C
//
|
|
// IfishCertifyImgFile.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 16/8/17.
|
|
// Copyright © 2016年 lianxiang. All rights reserved.
|
|
//
|
|
|
|
#import "IfishCertifyImgFile.h"
|
|
|
|
@implementation IfishCertifyImgFile
|
|
|
|
+(void)saveImageWithdata:(NSData*)data addImagIndex:(int)index{
|
|
|
|
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
|
|
|
NSString *savePath = nil;
|
|
|
|
savePath = [NSString stringWithFormat:@"%@/uploadImg/%d",rootPath,index];
|
|
NSFileManager *manager = [NSFileManager defaultManager];
|
|
if(![manager fileExistsAtPath:savePath]){
|
|
[manager createDirectoryAtPath:savePath withIntermediateDirectories:YES attributes:nil error:nil];
|
|
}
|
|
NSLog(@"savePath:%@",savePath);
|
|
[data writeToFile:[NSString stringWithFormat:@"%@/%d.png",savePath,index] atomically:YES];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
//取
|
|
+(NSString *)getImgWith :(int)index{
|
|
|
|
|
|
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
|
NSString *filePath = nil;
|
|
|
|
filePath = [NSString stringWithFormat:@"%@/uploadImg/%d/%d.png",rootPath,index,index];
|
|
|
|
NSLog(@"savePath:%@",filePath);
|
|
return filePath;
|
|
|
|
}
|
|
|
|
+(UIImage *)getImgeWith:(int)index{
|
|
|
|
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
|
NSString *filePath = nil;
|
|
|
|
filePath = [NSString stringWithFormat:@"%@/uploadImg/%d/%d.png",rootPath,index,index];
|
|
NSLog(@"savePath:%@",filePath);
|
|
UIImage *Img = [UIImage imageWithContentsOfFile:filePath];
|
|
|
|
|
|
|
|
return Img;
|
|
}
|
|
|
|
@end
|