nsurlcache

URLresponse is not retrieved after storing in cache using storeCachedResponse

◇◆丶佛笑我妖孽 提交于 2019-12-17 14:12:16
问题 Goal I'm trying to inject data/response from URLRequest into another URLRequest in my cache. Setup This is just a sample code. It's ready to be dumped into a project. What I'm trying to do is use the response + data retrieved from my landscapeURLString network request...store into my session's cache for my lizardURLString request. import UIKit class ViewController: UIViewController { lazy var defaultSession : URLSession = { let urlCache = URLCache(memoryCapacity: 500 * 1024 * 1024,

NSURLCache Memory Size is zero

我的未来我决定 提交于 2019-12-12 09:41:43
问题 I am having trouble caching NSURLConnection responses using a synchronous call. I initialize the cache in one class and then use it in another. Notice how the cache memory capacity gets initialized to 100KB but then is magically reset to zero later. - (id)init { if (self = [super init]) { // Creates a custom URL cache that uses both memory and disk. NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:kMemoryCacheSize * 1000000 diskCapacity:kDiskCacheSize * 1000000 diskPath

Caching videos in ios

若如初见. 提交于 2019-12-11 06:15:02
问题 I have the following method playing video on AVMediaPlayerController -(void)sendRequestForVideo { NSString*VideoStr=@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"; NSURL *url = [NSURL URLWithString:VideoStr]; AVPlayer *player = [AVPlayer playerWithURL:url]; AVPlayerViewController *controller = [[AVPlayerViewController alloc]init]; controller.player = player; [self addChildViewController:controller]; [self.view addSubview:controller.view]; controller.view.frame = self.view.frame;

How to clear cached data stored by URLSession/URLConfiguration?

我是研究僧i 提交于 2019-12-11 05:13:55
问题 I am using the code below to set the caching policy of my URLSession via URLConfiguration. if appDelegateObj.configuration == nil { appDelegateObj.configuration = URLSessionConfiguration.default } if self.apiType == ServerRequest.API_TYPES_NAME.API1 { if appDelegateObj.forceReload == true { appDelegateObj.configuration?.urlCache = nil appDelegateObj.configuration?.requestCachePolicy = .reloadIgnoringLocalCacheData }else{ appDelegateObj.configuration?.requestCachePolicy =

URLCache (iOS). storeCachedResponse works asynchronously. How to catch the completion?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 04:25:27
问题 Just discovered that the function storeCachedResponse(_ cachedResponse: CachedURLResponse, for request: URLRequest) works asynchronously. That is, the result is not returned immediately after execution. I did not find a description of this in the official documentation. See example: cache = URLCache(memoryCapacity: 0, diskCapacity: 100 * 1024 * 1024, diskPath: "myCache") let config = URLSessionConfiguration.default config.requestCachePolicy = .returnCacheDataElseLoad config.urlCache = cache

What happens if NSURLCache is full?

岁酱吖の 提交于 2019-12-10 19:56:00
问题 I'm using default NSURLCache to cache images in my iPhone app. What will happen if the cache is full and i'll try to cache another image? Will it not cache the image? or it will be replaced with the oldest image cached? Thanks alot 回答1: The maximum cache can be influenced with the initialization initWithMemoryCapacity:... diskCapacity:... diskPath:..] The new file will always be downloaded. (except when it's bigger than the maximum memory capacity, then it will just be downloaded and not

clearing a webviews cache for local files

这一生的挚爱 提交于 2019-12-09 10:08:32
问题 I've found some similar posts, but they don't seem to have any effect with what I'm doing. I've got a UIWebView that I'm using to display local content in my bundle. Specifically I'm displaying a docx file. The user should rarely ever look at this document, and my app is tight on memory, so what I want to do is prevent the UIWebView from caching the document. Another viable option is to clear the cache when the user leaves the view. I'm totally ok with having to load it from scratch every

On iOS where is the NSURLCache cache stored if diskPath:nil?

夙愿已清 提交于 2019-12-08 23:45:02
问题 I've come across code that looks like this: NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 diskCapacity:1024 * 1024 * 5 diskPath:nil]; The problem is that I haven't been able to find what's the expected behavior when diskPath is passed nil. NSURLCache docs don't explicitly describe this situation nor I have been able to figure it out with my own testing. Where is the cache stored? or is that code above a bug? Thanks. 回答1: I had some free time today to do some

Shared NSURLCache and UIWebView on iOS 8

狂风中的少年 提交于 2019-12-07 02:01:09
问题 In iOS 7, I was able to set a shared URL cache to a subclass of NSURLCache and any UIWebView s I created would automatically use that shared cache for each request. // Set the URL cache and leave it set permanently ExampleURLCache *cache = [[ExampleURLCache alloc] init]; [NSURLCache setSharedURLCache:cache]; However, now in iOS 8 it doesn't seem like UIWebView pulls from the shared cache and cachedResponseForRequest never gets called. Has anyone found documentation for this change, or a

How to clear cache of app in objective C?

╄→гoц情女王★ 提交于 2019-12-06 15:16:12
问题 I'm building an iOS app in which i have implemented Fabric and using Digits for login.When login is successful session remains open. I'm facing an issue i want to clear the app cache to reset the session so user can login again with a new phone number.But it is not happening. The code i'm using to clear the app cache: - (void)viewDidLoad { [super viewDidLoad]; [[NSURLCache sharedURLCache] removeAllCachedResponses]; } Help is appreciated! 回答1: Rather than go low-level and mess with NSURLCache,