YLCache Class Reference
Inherits from | NSObject |
Conforms to | NSCacheDelegate |
Declared in | YLCache.h YLCache.m |
Overview
YLCache is responsible for all PDF rendering related things. It can render PDF pages into images, load pre-rendered images from disk/memory and save rendered images to memory/disk.
Tasks
Initialization
-
+ sharedCache
Returns a reference to the singleton YLCache instance.
Caching Methods
-
– startCachingDocument:startPage:size:
Starts pre-caching the document in the background.
-
– stopCachingDocument:
Stops all load/render operations for a specific document.
-
– cancelOperation:
Cancels a load/render operation.
-
– cachedImageForDocument:page:size:
Use this function to request a pre-rendered image for a specific PDF page.
Delegate Methods
-
– addDelegate:delegateQueue:
Use this function to register yourself as a delegate.
-
– removeDelegate:
Use this function to unregister yourself as a delegate.
Helper Methods
-
– pauseCaching:
Use this function to pause rendering/caching operations running in the background. The search operation uses this function to temporarily pause caching while searching for text because it’s a CPU-heavy operation.
-
– resumeCaching:
Use this function to resume rendering/caching operations running in the background. Operations will only continue when YLCache is not waiting for other services.
-
– clearCache
This function will clear the memory cache.
-
– clearCacheForDocument:
This function will remove the cache on disk for a specific document.
Instance Methods
addDelegate:delegateQueue:
Use this function to register yourself as a delegate.
- (void)addDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue
Parameters
- delegate
Reference to the delegate object.
- delegateQueue
The queue on which the delegate should be informed. If you want to get informed on the main thread use dispatch_get_main_queue() here.
Discussion
Use this function to register yourself as a delegate.
Declared In
YLCache.h
cachedImageForDocument:page:size:
Use this function to request a pre-rendered image for a specific PDF page.
- (id)cachedImageForDocument:(YLDocument *)document page:(NSUInteger)page size:(YLPDFImageSize)size
Parameters
- document
Reference to the document.
- page
Page number starting from 0.
- size
Type of image that should be created for this page.
Return Value
A subclass of YLOperation (YLLoadOperation or YLRenderOperation) or an UIImage instance if the image is available in the cache.
Discussion
Use this function to request a pre-rendered image for a specific PDF page.
Declared In
YLCache.h
cancelOperation:
Cancels a load/render operation.
- (void)cancelOperation:(YLOperation *)operation
Parameters
- operation
An instance of YLLoadOperation or YLRenderOperation.
Discussion
Cancels a load/render operation.
Declared In
YLCache.h
clearCache
This function will clear the memory cache.
- (void)clearCache
Discussion
This function will clear the memory cache.
Declared In
YLCache.h
clearCacheForDocument:
This function will remove the cache on disk for a specific document.
- (void)clearCacheForDocument:(YLDocument *)document
Parameters
- document
Reference to the document.
Discussion
This function will remove the cache on disk for a specific document.
Declared In
YLCache.h
pauseCaching:
Use this function to pause rendering/caching operations running in the background. The search operation uses this function to temporarily pause caching while searching for text because it’s a CPU-heavy operation.
- (void)pauseCaching:(NSString *)caller
Parameters
- caller
String value that serves as an identifier. You must use the same identifier when calling resumeCaching!
Discussion
Use this function to pause rendering/caching operations running in the background. The search operation uses this function to temporarily pause caching while searching for text because it’s a CPU-heavy operation.
Declared In
YLCache.h
removeDelegate:
Use this function to unregister yourself as a delegate.
- (void)removeDelegate:(id)delegate
Parameters
- delegate
Reference to the delegate object.
Discussion
Use this function to unregister yourself as a delegate.
Declared In
YLCache.h
resumeCaching:
Use this function to resume rendering/caching operations running in the background. Operations will only continue when YLCache is not waiting for other services.
- (void)resumeCaching:(NSString *)caller
Parameters
- caller
String value that serves as an identifier. Use the same identifier you used when calling pauseCaching!
Discussion
Use this function to resume rendering/caching operations running in the background. Operations will only continue when YLCache is not waiting for other services.
Declared In
YLCache.h
startCachingDocument:startPage:size:
Starts pre-caching the document in the background.
- (void)startCachingDocument:(YLDocument *)document startPage:(NSUInteger)page size:(YLPDFImageSize)size
Parameters
- document
Reference to the document.
- page
Page number starting from 0. The document will be parsed starting from this page.
- size
This defines the type of images that should be created for this document.
Discussion
Starts pre-caching the document in the background.
Declared In
YLCache.h