Class: NSURLCache
Overview
NSURLCache implements the caching of responses to URL load requests by mapping NSURLRequest objects to NSCachedURLResponse objects. It is a composite of an in-memory and an on-disk cache.
Class Method Summary (collapse)
-
+ setSharedURLCache:
Sets the shared NSURLCache instance to a specified cache object.
-
+ sharedURLCache
Returns the shared NSURLCache instance.
Instance Method Summary (collapse)
-
- cachedResponseForRequest:
Returns the cached URL response in the cache for the specified URL request.
-
- currentDiskUsage
Returns the current size of the receiver’s on-disk cache, in bytes.
-
- currentMemoryUsage
Returns the current size of the receiver’s in-memory cache, in bytes.
-
- diskCapacity
Returns the capacity of the receiver’s on-disk cache, in bytes.
-
- initWithMemoryCapacity:diskCapacity:diskPath:
Initializes an NSURLCache object with the specified values.
-
- memoryCapacity
Returns the capacity of the receiver’s in-memory cache, in bytes.
-
- removeAllCachedResponses
Clears the receiver’s cache, removing all stored cached URL responses.
-
- removeCachedResponseForRequest:
Removes the cached URL response for a specified URL request.
-
- setDiskCapacity:
Sets the receiver’s on-disk cache capacity.
-
- setMemoryCapacity:
Sets the receiver’s in-memory cache capacity.
-
- storeCachedResponse:forRequest:
Stores a cached URL response for a specified request.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Class Method Details
+ (Object) setSharedURLCache(cache)
Sets the shared NSURLCache instance to a specified cache object. An application that has special caching requirements or constraints should use this method to specify an NSURLCache instance with customized cache settings. The application should do so before any calls to the sharedURLCache method.
+ (NSURLCache) sharedURLCache
Returns the shared NSURLCache instance. Applications that do not have special caching requirements or constraints should find the default shared cache instance acceptable. An application with more specific needs can create a custom NSURLCache object and set it as the shared cache instance using setSharedURLCache:. The application should do so before any calls to this method.
Instance Method Details
- (NSCachedURLResponse) cachedResponseForRequest(request)
Returns the cached URL response in the cache for the specified URL request.
- (Integer) currentDiskUsage
Returns the current size of the receiver’s on-disk cache, in bytes.
- (Integer) currentMemoryUsage
Returns the current size of the receiver’s in-memory cache, in bytes.
- (Integer) diskCapacity
Returns the capacity of the receiver’s on-disk cache, in bytes.
- (Object) initWithMemoryCapacity(memoryCapacity, diskCapacity:diskCapacity, diskPath:path)
Initializes an NSURLCache object with the specified values. The returned NSURLCache is backed by disk, so developers can be more liberal with space when choosing the capacity for this kind of cache. A disk cache measured in the tens of megabytes should be acceptable in most cases.
- (Integer) memoryCapacity
Returns the capacity of the receiver’s in-memory cache, in bytes.
- (Object) removeAllCachedResponses
Clears the receiver’s cache, removing all stored cached URL responses.
- (Object) removeCachedResponseForRequest(request)
Removes the cached URL response for a specified URL request.
- (Object) setDiskCapacity(diskCapacity)
Sets the receiver’s on-disk cache capacity
- (Object) setMemoryCapacity(memoryCapacity)
Sets the receiver’s in-memory cache capacity.
- (Object) storeCachedResponse(cachedResponse, forRequest:request)
Stores a cached URL response for a specified request