XHNetworkCache: one line of code writes request data to the disk cache, and one line of xhnetworkcache
XHNetworkCache
Version record (continuous update) 2016.07.01 Version 1.1 (update)
- 1. added the interface for manually clearing the cache.
- 2. added the interface for obtaining cache size.
2016.06.24 Version 1.0 (released) usage:
1. Write
[Objective-C] Check the source file copy code?
123 |
// Write data to the disk cache (parameter 1: JSON data returned by the server, parameter 2: Data request URL) // [Cache data by APP version number. data cached on the same interface for different apps of different versions does not interfere with each other] [XHNetworkCache saveJsonResponseToCacheFile:responseObject andURL:URLString]; |
2. Get
[Objective-C] Check the source file copy code?
12 |
// Obtain the cached data (parameter: request URL, return: JSON data) id JsonCache = [XHNetworkCache cacheJsonWithURL:URLString]; |
3. Clear Cache
[Objective-C] Check the source file copy code?
12 |
// Clear Cache [XHNetworkCache clearCache]; |
4. Get the total cache size (M)
[Objective-C] Check the source file copy code?
12 |
// Obtain the total cache size (MB) float cacheSize = [XHNetworkCache cacheSize]; |
Install and manually add:
- 1. Add the XHNetworkCache folder to the project directory.
- 2. Import XHNetworkCache. h
CocoaPods:
- 1. Add pod 'xhnetworkcache' to Podfile'
- 2. Run pod install or pod update.
- 3. Import XHNetworkCache. h
System Requirements
- This project supports iOS 7.0 and Xcode 7.0 at the minimum.
Code:
Http://www.code4app.com/forum.php? Mod = viewthread & tid = 9145 & extra = page % 3D2% 26 filter % 3 Dsortid % 26 orderby % 3 Ddateline % 26 sortid % 3D1