我在文档目录中保存了一张图片,但是当我尝试读取它时,似乎根本没有保存该文件。读取路径OK,和save一样。
[_IDBanners addObject:@"44"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory
NSString * name = [NSString stringWithFormat:@"%@.png",[_IDBanners objectAtIndex:i]];
NSString *filePath = [documentsPath stringByAppendingPathComponent:name]; //Add the file name
NSData *pngData = [NSData dataWithContentsOfFile:filePath];
UIImage *image = [UIImage imageWithData:pngData];
当我登录时:
NSLog(@"%@",image);
它返回(空)。