nscache

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 =

How to cache data in ios

做~自己de王妃 提交于 2019-12-10 23:16:16
问题 I loaded XML data (including images, text,...) from server and display that data on iphone screen. How can i cache data to re-load that screen when i visit that screen other time. It will be faster . (dont need re-load XML data again)? Thank you. 回答1: Use EGOcache API. Just import the EGOCache.h file in your class - (void)setObject:(id<NSCoding>)anObject forKey:(NSString*)key; -(void)setObject:(id)anObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; -(id

NSCache - marking object not-removable

此生再无相见时 提交于 2019-12-08 07:39:34
问题 When user switches between view controllers via menu, I want to cache them if he has enough memory. In order to do so, I want to use NSCache to store many UIViewControllers . However, I'm not sure how I can tell NSCache that current object is currently used and should not be removed. E.g, when I run app, load few view controllers and quit the app, NSCache automatically delete all viewControllers (which makes sense - app will be able to stay longer in the foreground). However, it also removes

NSCache to store images for UITableView In Swift

邮差的信 提交于 2019-12-08 03:42:01
问题 I'm new in swift programming and I have searched a lot about storing images with NSCache using Swift. What I have done so far is that I'm getting id s and imageName s with JSON and I have my data in array and I was able to display image in cells with no problem. Now I want to cache images. This is the code that I have written: override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView

Empty the cache programmatically in iOS

余生长醉 提交于 2019-12-07 02:26:46
问题 Does anyone by coincidence know how I can empty the cache memory of the iOS app that I am developing, in the moment it goes to the background (applicationDidEnterBackground)? I have investigated about NSCache but I am still not able to understand how could I retrieve the cache to basically remove/free it? 回答1: Is this what you're talking about? [[NSURLCache sharedURLCache] removeAllCachedResponses]; You can also modify the cache behavior of your requests to selectively cache responses. If you

Empty the cache programmatically in iOS

早过忘川 提交于 2019-12-05 08:42:55
Does anyone by coincidence know how I can empty the cache memory of the iOS app that I am developing, in the moment it goes to the background (applicationDidEnterBackground)? I have investigated about NSCache but I am still not able to understand how could I retrieve the cache to basically remove/free it? Is this what you're talking about? [[NSURLCache sharedURLCache] removeAllCachedResponses]; You can also modify the cache behavior of your requests to selectively cache responses. If you're using AFNetworking by chance, you can use setCacheResponseBlock . E.g. in one project I set it to return

Right place to store the application data in IOS

扶醉桌前 提交于 2019-12-01 07:28:41
问题 Currently i was saving my application data (Media) to the CacheDirectory i.e /var/mobile/Applications/BEAFC76C-C450-4A3A-9765-A0385A9580F3/Library/Caches and things were going fine. But recently i got a bug report that the application data has been deleted. When i searched over it, i got this Apple Doc. According to it, DocumentsDirectory should be the ideal place to store the User/Application data. Put user data in the /Documents/. User data is any data that cannot be recreated by your app,

NSCache emptied when app enters background

99封情书 提交于 2019-12-01 01:20:19
问题 I currently use a Subclass of NSCache to store some images (values) with their corresponding names (Keys) and it seems to work fine, when the app is in the foreground. However, when I press the home button/the user enters the background and I reenter the app, the NSCache is empty. Implementation details: I implemented my subclass of NSCache as a Singleton. This ensures that there should be only one instance of that class, which should be accessible from anywhere in the program by simply

NSCache and background

江枫思渺然 提交于 2019-11-30 06:47:30
I've noticed that NSCache evicts all of its object when the application goes in background. is that the expected behaviour? is there a way to avoid it? I would expect it to evict objects when the device run out of memory not immediately when the app goes in background. Do you know any valid alternative? In my case, that happened when objects stored in NSCache does not conform to NSDiscardableContent protocol. When I added the said protocol, eviction of objects when the app is entering background disappears. In addition, based on source of NSCache.m I found here , objects that do not conform to

How to store data in NSCache in ios?

纵然是瞬间 提交于 2019-11-30 04:49:44
问题 I am very new to NSCache. I have an API call which results in several objects.How to store these objects in NSCache so that I don't require to call the API again. How much data can be stored in NSCache. Is there a specific limit to store the data in NSCache. Please help me. 回答1: Take a look at documentation and sample code. An NSCache object is a collection-like container, or cache, that stores key-value pairs, similar to the NSDictionary class. Here is good explanation by Nick Zitzmann.