Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios AFN正在缓存图像,而不在Swift的ImageView中显示它_Ios_Objective C_Swift_Afnetworking - Fatal编程技术网

Ios AFN正在缓存图像,而不在Swift的ImageView中显示它

Ios AFN正在缓存图像,而不在Swift的ImageView中显示它,ios,objective-c,swift,afnetworking,Ios,Objective C,Swift,Afnetworking,我知道AFNetworking有一个功能,可以在图像加载到ImageView时缓存图像 但是,我想缓存图像而不在ImageView中显示它,我找不到任何相关函数。使用[NSBundle mainBundle]resourcePath]获取缓存路径,然后使用NSFileManager编写文件/对象/文档等。类似这样的东西(目标C不是Swift-但你明白了) 实现savePNGImage以在本地保存图像 AFHTTPRequestOperation *requestOperation = [[AFH

我知道AFNetworking有一个功能,可以在图像加载到ImageView时缓存图像


但是,我想缓存图像而不在ImageView中显示它,我找不到任何相关函数。

使用[NSBundle mainBundle]resourcePath]获取缓存路径,然后使用NSFileManager编写文件/对象/文档等。

类似这样的东西(目标C不是Swift-但你明白了)

实现savePNGImage以在本地保存图像

AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];

requestOperation.responseSerializer = [AFImageResponseSerializer serializer];

[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

    [self savePNGImage:responseObject withFilename:imageUrl];

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"%@", [error description]);
}];
[requestOperation start];