Commit a75c6cba1ee7d6339cd66f002ff2519695a36e09

Authored by 王帅
1 parent f9e5513d

no message

WSWebImageDemo.xcodeproj/project.pbxproj 0 → 100644
  1 +// !$*UTF8*$!
  2 +{
  3 + archiveVersion = 1;
  4 + classes = {
  5 + };
  6 + objectVersion = 46;
  7 + objects = {
  8 +
  9 +/* Begin PBXBuildFile section */
  10 + 0339FBE71D48A94000E4EDAB /* CNLiveWebImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0339FBE61D48A94000E4EDAB /* CNLiveWebImageManager.m */; };
  11 + 0339FBE91D48B7EF00E4EDAB /* text.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 0339FBE81D48B7EF00E4EDAB /* text.jpg */; };
  12 + 036922401D4732C300F4E378 /* UIImageView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 0369223F1D4732C300F4E378 /* UIImageView+WebCache.m */; };
  13 + 036CBF251D3731260044A601 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 036CBF241D3731260044A601 /* main.m */; };
  14 + 036CBF281D3731260044A601 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 036CBF271D3731260044A601 /* AppDelegate.m */; };
  15 + 036CBF2B1D3731260044A601 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 036CBF2A1D3731260044A601 /* ViewController.m */; };
  16 + 036CBF2E1D3731260044A601 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 036CBF2C1D3731260044A601 /* Main.storyboard */; };
  17 + 036CBF301D3731260044A601 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 036CBF2F1D3731260044A601 /* Assets.xcassets */; };
  18 + 036CBF331D3731260044A601 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 036CBF311D3731260044A601 /* LaunchScreen.storyboard */; };
  19 + 036CBF3E1D3731260044A601 /* WSWebImageDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 036CBF3D1D3731260044A601 /* WSWebImageDemoTests.m */; };
  20 + 036CBF491D3731260044A601 /* WSWebImageDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 036CBF481D3731260044A601 /* WSWebImageDemoUITests.m */; };
  21 + 036CBF581D3731DE0044A601 /* CNLiveWebImageDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = 036CBF571D3731DE0044A601 /* CNLiveWebImageDownload.m */; };
  22 + 038293CA1D40CE2F005E6252 /* UIImage+MultiFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 038293C91D40CE2F005E6252 /* UIImage+MultiFormat.m */; };
  23 + 038293CD1D40CE72005E6252 /* NSData+ImageContentType.m in Sources */ = {isa = PBXBuildFile; fileRef = 038293CC1D40CE72005E6252 /* NSData+ImageContentType.m */; };
  24 + 03AA3F601D3E1F1E00EC7E54 /* CNLiveImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 03AA3F5F1D3E1F1E00EC7E54 /* CNLiveImageCache.m */; };
  25 + 03E8B4891D45DEFD00980A27 /* CNLiveWebImageDownloadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 03E8B4881D45DEFD00980A27 /* CNLiveWebImageDownloadOperation.m */; };
  26 +/* End PBXBuildFile section */
  27 +
  28 +/* Begin PBXContainerItemProxy section */
  29 + 036CBF3A1D3731260044A601 /* PBXContainerItemProxy */ = {
  30 + isa = PBXContainerItemProxy;
  31 + containerPortal = 036CBF181D3731260044A601 /* Project object */;
  32 + proxyType = 1;
  33 + remoteGlobalIDString = 036CBF1F1D3731260044A601;
  34 + remoteInfo = WSWebImageDemo;
  35 + };
  36 + 036CBF451D3731260044A601 /* PBXContainerItemProxy */ = {
  37 + isa = PBXContainerItemProxy;
  38 + containerPortal = 036CBF181D3731260044A601 /* Project object */;
  39 + proxyType = 1;
  40 + remoteGlobalIDString = 036CBF1F1D3731260044A601;
  41 + remoteInfo = WSWebImageDemo;
  42 + };
  43 +/* End PBXContainerItemProxy section */
  44 +
  45 +/* Begin PBXFileReference section */
  46 + 0339FBE41D489DBF00E4EDAB /* CNLiveWebImageBlock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveWebImageBlock.h; sourceTree = "<group>"; };
  47 + 0339FBE51D48A94000E4EDAB /* CNLiveWebImageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveWebImageManager.h; sourceTree = "<group>"; };
  48 + 0339FBE61D48A94000E4EDAB /* CNLiveWebImageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveWebImageManager.m; sourceTree = "<group>"; };
  49 + 0339FBE81D48B7EF00E4EDAB /* text.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = text.jpg; sourceTree = "<group>"; };
  50 + 0369223E1D4732C300F4E378 /* UIImageView+WebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+WebCache.h"; sourceTree = "<group>"; };
  51 + 0369223F1D4732C300F4E378 /* UIImageView+WebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+WebCache.m"; sourceTree = "<group>"; };
  52 + 036CBF201D3731260044A601 /* WSWebImageDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WSWebImageDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
  53 + 036CBF241D3731260044A601 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
  54 + 036CBF261D3731260044A601 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
  55 + 036CBF271D3731260044A601 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
  56 + 036CBF291D3731260044A601 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
  57 + 036CBF2A1D3731260044A601 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
  58 + 036CBF2D1D3731260044A601 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
  59 + 036CBF2F1D3731260044A601 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
  60 + 036CBF321D3731260044A601 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
  61 + 036CBF341D3731260044A601 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  62 + 036CBF391D3731260044A601 /* WSWebImageDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WSWebImageDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
  63 + 036CBF3D1D3731260044A601 /* WSWebImageDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WSWebImageDemoTests.m; sourceTree = "<group>"; };
  64 + 036CBF3F1D3731260044A601 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  65 + 036CBF441D3731260044A601 /* WSWebImageDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WSWebImageDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
  66 + 036CBF481D3731260044A601 /* WSWebImageDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WSWebImageDemoUITests.m; sourceTree = "<group>"; };
  67 + 036CBF4A1D3731260044A601 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  68 + 036CBF561D3731DE0044A601 /* CNLiveWebImageDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveWebImageDownload.h; sourceTree = "<group>"; };
  69 + 036CBF571D3731DE0044A601 /* CNLiveWebImageDownload.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveWebImageDownload.m; sourceTree = "<group>"; };
  70 + 038293C81D40CE2F005E6252 /* UIImage+MultiFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+MultiFormat.h"; sourceTree = "<group>"; };
  71 + 038293C91D40CE2F005E6252 /* UIImage+MultiFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+MultiFormat.m"; sourceTree = "<group>"; };
  72 + 038293CB1D40CE72005E6252 /* NSData+ImageContentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+ImageContentType.h"; sourceTree = "<group>"; };
  73 + 038293CC1D40CE72005E6252 /* NSData+ImageContentType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+ImageContentType.m"; sourceTree = "<group>"; };
  74 + 03AA3F5D1D3E1D3F00EC7E54 /* CNLiveWebImageOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveWebImageOperation.h; sourceTree = "<group>"; };
  75 + 03AA3F5E1D3E1F1E00EC7E54 /* CNLiveImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveImageCache.h; sourceTree = "<group>"; };
  76 + 03AA3F5F1D3E1F1E00EC7E54 /* CNLiveImageCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveImageCache.m; sourceTree = "<group>"; };
  77 + 03E8B4871D45DEFD00980A27 /* CNLiveWebImageDownloadOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveWebImageDownloadOperation.h; sourceTree = "<group>"; };
  78 + 03E8B4881D45DEFD00980A27 /* CNLiveWebImageDownloadOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveWebImageDownloadOperation.m; sourceTree = "<group>"; };
  79 +/* End PBXFileReference section */
  80 +
  81 +/* Begin PBXFrameworksBuildPhase section */
  82 + 036CBF1D1D3731260044A601 /* Frameworks */ = {
  83 + isa = PBXFrameworksBuildPhase;
  84 + buildActionMask = 2147483647;
  85 + files = (
  86 + );
  87 + runOnlyForDeploymentPostprocessing = 0;
  88 + };
  89 + 036CBF361D3731260044A601 /* Frameworks */ = {
  90 + isa = PBXFrameworksBuildPhase;
  91 + buildActionMask = 2147483647;
  92 + files = (
  93 + );
  94 + runOnlyForDeploymentPostprocessing = 0;
  95 + };
  96 + 036CBF411D3731260044A601 /* Frameworks */ = {
  97 + isa = PBXFrameworksBuildPhase;
  98 + buildActionMask = 2147483647;
  99 + files = (
  100 + );
  101 + runOnlyForDeploymentPostprocessing = 0;
  102 + };
  103 +/* End PBXFrameworksBuildPhase section */
  104 +
  105 +/* Begin PBXGroup section */
  106 + 036CBF171D3731260044A601 = {
  107 + isa = PBXGroup;
  108 + children = (
  109 + 036CBF221D3731260044A601 /* WSWebImageDemo */,
  110 + 036CBF3C1D3731260044A601 /* WSWebImageDemoTests */,
  111 + 036CBF471D3731260044A601 /* WSWebImageDemoUITests */,
  112 + 036CBF211D3731260044A601 /* Products */,
  113 + );
  114 + sourceTree = "<group>";
  115 + };
  116 + 036CBF211D3731260044A601 /* Products */ = {
  117 + isa = PBXGroup;
  118 + children = (
  119 + 036CBF201D3731260044A601 /* WSWebImageDemo.app */,
  120 + 036CBF391D3731260044A601 /* WSWebImageDemoTests.xctest */,
  121 + 036CBF441D3731260044A601 /* WSWebImageDemoUITests.xctest */,
  122 + );
  123 + name = Products;
  124 + sourceTree = "<group>";
  125 + };
  126 + 036CBF221D3731260044A601 /* WSWebImageDemo */ = {
  127 + isa = PBXGroup;
  128 + children = (
  129 + 0339FBE81D48B7EF00E4EDAB /* text.jpg */,
  130 + 036CBF261D3731260044A601 /* AppDelegate.h */,
  131 + 036CBF271D3731260044A601 /* AppDelegate.m */,
  132 + 036CBF291D3731260044A601 /* ViewController.h */,
  133 + 036CBF2A1D3731260044A601 /* ViewController.m */,
  134 + 0339FBE51D48A94000E4EDAB /* CNLiveWebImageManager.h */,
  135 + 0339FBE61D48A94000E4EDAB /* CNLiveWebImageManager.m */,
  136 + 036CBF561D3731DE0044A601 /* CNLiveWebImageDownload.h */,
  137 + 036CBF571D3731DE0044A601 /* CNLiveWebImageDownload.m */,
  138 + 03E8B4871D45DEFD00980A27 /* CNLiveWebImageDownloadOperation.h */,
  139 + 03E8B4881D45DEFD00980A27 /* CNLiveWebImageDownloadOperation.m */,
  140 + 0339FBE41D489DBF00E4EDAB /* CNLiveWebImageBlock.h */,
  141 + 03AA3F5D1D3E1D3F00EC7E54 /* CNLiveWebImageOperation.h */,
  142 + 03AA3F5E1D3E1F1E00EC7E54 /* CNLiveImageCache.h */,
  143 + 03AA3F5F1D3E1F1E00EC7E54 /* CNLiveImageCache.m */,
  144 + 038293C81D40CE2F005E6252 /* UIImage+MultiFormat.h */,
  145 + 038293C91D40CE2F005E6252 /* UIImage+MultiFormat.m */,
  146 + 038293CB1D40CE72005E6252 /* NSData+ImageContentType.h */,
  147 + 038293CC1D40CE72005E6252 /* NSData+ImageContentType.m */,
  148 + 0369223E1D4732C300F4E378 /* UIImageView+WebCache.h */,
  149 + 0369223F1D4732C300F4E378 /* UIImageView+WebCache.m */,
  150 + 036CBF2C1D3731260044A601 /* Main.storyboard */,
  151 + 036CBF2F1D3731260044A601 /* Assets.xcassets */,
  152 + 036CBF311D3731260044A601 /* LaunchScreen.storyboard */,
  153 + 036CBF341D3731260044A601 /* Info.plist */,
  154 + 036CBF231D3731260044A601 /* Supporting Files */,
  155 + );
  156 + path = WSWebImageDemo;
  157 + sourceTree = "<group>";
  158 + };
  159 + 036CBF231D3731260044A601 /* Supporting Files */ = {
  160 + isa = PBXGroup;
  161 + children = (
  162 + 036CBF241D3731260044A601 /* main.m */,
  163 + );
  164 + name = "Supporting Files";
  165 + sourceTree = "<group>";
  166 + };
  167 + 036CBF3C1D3731260044A601 /* WSWebImageDemoTests */ = {
  168 + isa = PBXGroup;
  169 + children = (
  170 + 036CBF3D1D3731260044A601 /* WSWebImageDemoTests.m */,
  171 + 036CBF3F1D3731260044A601 /* Info.plist */,
  172 + );
  173 + path = WSWebImageDemoTests;
  174 + sourceTree = "<group>";
  175 + };
  176 + 036CBF471D3731260044A601 /* WSWebImageDemoUITests */ = {
  177 + isa = PBXGroup;
  178 + children = (
  179 + 036CBF481D3731260044A601 /* WSWebImageDemoUITests.m */,
  180 + 036CBF4A1D3731260044A601 /* Info.plist */,
  181 + );
  182 + path = WSWebImageDemoUITests;
  183 + sourceTree = "<group>";
  184 + };
  185 +/* End PBXGroup section */
  186 +
  187 +/* Begin PBXNativeTarget section */
  188 + 036CBF1F1D3731260044A601 /* WSWebImageDemo */ = {
  189 + isa = PBXNativeTarget;
  190 + buildConfigurationList = 036CBF4D1D3731260044A601 /* Build configuration list for PBXNativeTarget "WSWebImageDemo" */;
  191 + buildPhases = (
  192 + 036CBF1C1D3731260044A601 /* Sources */,
  193 + 036CBF1D1D3731260044A601 /* Frameworks */,
  194 + 036CBF1E1D3731260044A601 /* Resources */,
  195 + );
  196 + buildRules = (
  197 + );
  198 + dependencies = (
  199 + );
  200 + name = WSWebImageDemo;
  201 + productName = WSWebImageDemo;
  202 + productReference = 036CBF201D3731260044A601 /* WSWebImageDemo.app */;
  203 + productType = "com.apple.product-type.application";
  204 + };
  205 + 036CBF381D3731260044A601 /* WSWebImageDemoTests */ = {
  206 + isa = PBXNativeTarget;
  207 + buildConfigurationList = 036CBF501D3731260044A601 /* Build configuration list for PBXNativeTarget "WSWebImageDemoTests" */;
  208 + buildPhases = (
  209 + 036CBF351D3731260044A601 /* Sources */,
  210 + 036CBF361D3731260044A601 /* Frameworks */,
  211 + 036CBF371D3731260044A601 /* Resources */,
  212 + );
  213 + buildRules = (
  214 + );
  215 + dependencies = (
  216 + 036CBF3B1D3731260044A601 /* PBXTargetDependency */,
  217 + );
  218 + name = WSWebImageDemoTests;
  219 + productName = WSWebImageDemoTests;
  220 + productReference = 036CBF391D3731260044A601 /* WSWebImageDemoTests.xctest */;
  221 + productType = "com.apple.product-type.bundle.unit-test";
  222 + };
  223 + 036CBF431D3731260044A601 /* WSWebImageDemoUITests */ = {
  224 + isa = PBXNativeTarget;
  225 + buildConfigurationList = 036CBF531D3731260044A601 /* Build configuration list for PBXNativeTarget "WSWebImageDemoUITests" */;
  226 + buildPhases = (
  227 + 036CBF401D3731260044A601 /* Sources */,
  228 + 036CBF411D3731260044A601 /* Frameworks */,
  229 + 036CBF421D3731260044A601 /* Resources */,
  230 + );
  231 + buildRules = (
  232 + );
  233 + dependencies = (
  234 + 036CBF461D3731260044A601 /* PBXTargetDependency */,
  235 + );
  236 + name = WSWebImageDemoUITests;
  237 + productName = WSWebImageDemoUITests;
  238 + productReference = 036CBF441D3731260044A601 /* WSWebImageDemoUITests.xctest */;
  239 + productType = "com.apple.product-type.bundle.ui-testing";
  240 + };
  241 +/* End PBXNativeTarget section */
  242 +
  243 +/* Begin PBXProject section */
  244 + 036CBF181D3731260044A601 /* Project object */ = {
  245 + isa = PBXProject;
  246 + attributes = {
  247 + LastUpgradeCheck = 0730;
  248 + ORGANIZATIONNAME = "王帅";
  249 + TargetAttributes = {
  250 + 036CBF1F1D3731260044A601 = {
  251 + CreatedOnToolsVersion = 7.3.1;
  252 + };
  253 + 036CBF381D3731260044A601 = {
  254 + CreatedOnToolsVersion = 7.3.1;
  255 + TestTargetID = 036CBF1F1D3731260044A601;
  256 + };
  257 + 036CBF431D3731260044A601 = {
  258 + CreatedOnToolsVersion = 7.3.1;
  259 + TestTargetID = 036CBF1F1D3731260044A601;
  260 + };
  261 + };
  262 + };
  263 + buildConfigurationList = 036CBF1B1D3731260044A601 /* Build configuration list for PBXProject "WSWebImageDemo" */;
  264 + compatibilityVersion = "Xcode 3.2";
  265 + developmentRegion = English;
  266 + hasScannedForEncodings = 0;
  267 + knownRegions = (
  268 + en,
  269 + Base,
  270 + );
  271 + mainGroup = 036CBF171D3731260044A601;
  272 + productRefGroup = 036CBF211D3731260044A601 /* Products */;
  273 + projectDirPath = "";
  274 + projectRoot = "";
  275 + targets = (
  276 + 036CBF1F1D3731260044A601 /* WSWebImageDemo */,
  277 + 036CBF381D3731260044A601 /* WSWebImageDemoTests */,
  278 + 036CBF431D3731260044A601 /* WSWebImageDemoUITests */,
  279 + );
  280 + };
  281 +/* End PBXProject section */
  282 +
  283 +/* Begin PBXResourcesBuildPhase section */
  284 + 036CBF1E1D3731260044A601 /* Resources */ = {
  285 + isa = PBXResourcesBuildPhase;
  286 + buildActionMask = 2147483647;
  287 + files = (
  288 + 0339FBE91D48B7EF00E4EDAB /* text.jpg in Resources */,
  289 + 036CBF331D3731260044A601 /* LaunchScreen.storyboard in Resources */,
  290 + 036CBF301D3731260044A601 /* Assets.xcassets in Resources */,
  291 + 036CBF2E1D3731260044A601 /* Main.storyboard in Resources */,
  292 + );
  293 + runOnlyForDeploymentPostprocessing = 0;
  294 + };
  295 + 036CBF371D3731260044A601 /* Resources */ = {
  296 + isa = PBXResourcesBuildPhase;
  297 + buildActionMask = 2147483647;
  298 + files = (
  299 + );
  300 + runOnlyForDeploymentPostprocessing = 0;
  301 + };
  302 + 036CBF421D3731260044A601 /* Resources */ = {
  303 + isa = PBXResourcesBuildPhase;
  304 + buildActionMask = 2147483647;
  305 + files = (
  306 + );
  307 + runOnlyForDeploymentPostprocessing = 0;
  308 + };
  309 +/* End PBXResourcesBuildPhase section */
  310 +
  311 +/* Begin PBXSourcesBuildPhase section */
  312 + 036CBF1C1D3731260044A601 /* Sources */ = {
  313 + isa = PBXSourcesBuildPhase;
  314 + buildActionMask = 2147483647;
  315 + files = (
  316 + 036CBF2B1D3731260044A601 /* ViewController.m in Sources */,
  317 + 036CBF581D3731DE0044A601 /* CNLiveWebImageDownload.m in Sources */,
  318 + 036922401D4732C300F4E378 /* UIImageView+WebCache.m in Sources */,
  319 + 03AA3F601D3E1F1E00EC7E54 /* CNLiveImageCache.m in Sources */,
  320 + 0339FBE71D48A94000E4EDAB /* CNLiveWebImageManager.m in Sources */,
  321 + 036CBF281D3731260044A601 /* AppDelegate.m in Sources */,
  322 + 038293CD1D40CE72005E6252 /* NSData+ImageContentType.m in Sources */,
  323 + 03E8B4891D45DEFD00980A27 /* CNLiveWebImageDownloadOperation.m in Sources */,
  324 + 038293CA1D40CE2F005E6252 /* UIImage+MultiFormat.m in Sources */,
  325 + 036CBF251D3731260044A601 /* main.m in Sources */,
  326 + );
  327 + runOnlyForDeploymentPostprocessing = 0;
  328 + };
  329 + 036CBF351D3731260044A601 /* Sources */ = {
  330 + isa = PBXSourcesBuildPhase;
  331 + buildActionMask = 2147483647;
  332 + files = (
  333 + 036CBF3E1D3731260044A601 /* WSWebImageDemoTests.m in Sources */,
  334 + );
  335 + runOnlyForDeploymentPostprocessing = 0;
  336 + };
  337 + 036CBF401D3731260044A601 /* Sources */ = {
  338 + isa = PBXSourcesBuildPhase;
  339 + buildActionMask = 2147483647;
  340 + files = (
  341 + 036CBF491D3731260044A601 /* WSWebImageDemoUITests.m in Sources */,
  342 + );
  343 + runOnlyForDeploymentPostprocessing = 0;
  344 + };
  345 +/* End PBXSourcesBuildPhase section */
  346 +
  347 +/* Begin PBXTargetDependency section */
  348 + 036CBF3B1D3731260044A601 /* PBXTargetDependency */ = {
  349 + isa = PBXTargetDependency;
  350 + target = 036CBF1F1D3731260044A601 /* WSWebImageDemo */;
  351 + targetProxy = 036CBF3A1D3731260044A601 /* PBXContainerItemProxy */;
  352 + };
  353 + 036CBF461D3731260044A601 /* PBXTargetDependency */ = {
  354 + isa = PBXTargetDependency;
  355 + target = 036CBF1F1D3731260044A601 /* WSWebImageDemo */;
  356 + targetProxy = 036CBF451D3731260044A601 /* PBXContainerItemProxy */;
  357 + };
  358 +/* End PBXTargetDependency section */
  359 +
  360 +/* Begin PBXVariantGroup section */
  361 + 036CBF2C1D3731260044A601 /* Main.storyboard */ = {
  362 + isa = PBXVariantGroup;
  363 + children = (
  364 + 036CBF2D1D3731260044A601 /* Base */,
  365 + );
  366 + name = Main.storyboard;
  367 + sourceTree = "<group>";
  368 + };
  369 + 036CBF311D3731260044A601 /* LaunchScreen.storyboard */ = {
  370 + isa = PBXVariantGroup;
  371 + children = (
  372 + 036CBF321D3731260044A601 /* Base */,
  373 + );
  374 + name = LaunchScreen.storyboard;
  375 + sourceTree = "<group>";
  376 + };
  377 +/* End PBXVariantGroup section */
  378 +
  379 +/* Begin XCBuildConfiguration section */
  380 + 036CBF4B1D3731260044A601 /* Debug */ = {
  381 + isa = XCBuildConfiguration;
  382 + buildSettings = {
  383 + ALWAYS_SEARCH_USER_PATHS = NO;
  384 + CLANG_ANALYZER_NONNULL = YES;
  385 + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
  386 + CLANG_CXX_LIBRARY = "libc++";
  387 + CLANG_ENABLE_MODULES = YES;
  388 + CLANG_ENABLE_OBJC_ARC = YES;
  389 + CLANG_WARN_BOOL_CONVERSION = YES;
  390 + CLANG_WARN_CONSTANT_CONVERSION = YES;
  391 + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
  392 + CLANG_WARN_EMPTY_BODY = YES;
  393 + CLANG_WARN_ENUM_CONVERSION = YES;
  394 + CLANG_WARN_INT_CONVERSION = YES;
  395 + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
  396 + CLANG_WARN_UNREACHABLE_CODE = YES;
  397 + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
  398 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
  399 + COPY_PHASE_STRIP = NO;
  400 + DEBUG_INFORMATION_FORMAT = dwarf;
  401 + ENABLE_STRICT_OBJC_MSGSEND = YES;
  402 + ENABLE_TESTABILITY = YES;
  403 + GCC_C_LANGUAGE_STANDARD = gnu99;
  404 + GCC_DYNAMIC_NO_PIC = NO;
  405 + GCC_NO_COMMON_BLOCKS = YES;
  406 + GCC_OPTIMIZATION_LEVEL = 0;
  407 + GCC_PREPROCESSOR_DEFINITIONS = (
  408 + "DEBUG=1",
  409 + "$(inherited)",
  410 + );
  411 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
  412 + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
  413 + GCC_WARN_UNDECLARED_SELECTOR = YES;
  414 + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
  415 + GCC_WARN_UNUSED_FUNCTION = YES;
  416 + GCC_WARN_UNUSED_VARIABLE = YES;
  417 + IPHONEOS_DEPLOYMENT_TARGET = 9.3;
  418 + MTL_ENABLE_DEBUG_INFO = YES;
  419 + ONLY_ACTIVE_ARCH = YES;
  420 + SDKROOT = iphoneos;
  421 + TARGETED_DEVICE_FAMILY = "1,2";
  422 + };
  423 + name = Debug;
  424 + };
  425 + 036CBF4C1D3731260044A601 /* Release */ = {
  426 + isa = XCBuildConfiguration;
  427 + buildSettings = {
  428 + ALWAYS_SEARCH_USER_PATHS = NO;
  429 + CLANG_ANALYZER_NONNULL = YES;
  430 + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
  431 + CLANG_CXX_LIBRARY = "libc++";
  432 + CLANG_ENABLE_MODULES = YES;
  433 + CLANG_ENABLE_OBJC_ARC = YES;
  434 + CLANG_WARN_BOOL_CONVERSION = YES;
  435 + CLANG_WARN_CONSTANT_CONVERSION = YES;
  436 + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
  437 + CLANG_WARN_EMPTY_BODY = YES;
  438 + CLANG_WARN_ENUM_CONVERSION = YES;
  439 + CLANG_WARN_INT_CONVERSION = YES;
  440 + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
  441 + CLANG_WARN_UNREACHABLE_CODE = YES;
  442 + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
  443 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
  444 + COPY_PHASE_STRIP = NO;
  445 + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
  446 + ENABLE_NS_ASSERTIONS = NO;
  447 + ENABLE_STRICT_OBJC_MSGSEND = YES;
  448 + GCC_C_LANGUAGE_STANDARD = gnu99;
  449 + GCC_NO_COMMON_BLOCKS = YES;
  450 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
  451 + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
  452 + GCC_WARN_UNDECLARED_SELECTOR = YES;
  453 + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
  454 + GCC_WARN_UNUSED_FUNCTION = YES;
  455 + GCC_WARN_UNUSED_VARIABLE = YES;
  456 + IPHONEOS_DEPLOYMENT_TARGET = 9.3;
  457 + MTL_ENABLE_DEBUG_INFO = NO;
  458 + SDKROOT = iphoneos;
  459 + TARGETED_DEVICE_FAMILY = "1,2";
  460 + VALIDATE_PRODUCT = YES;
  461 + };
  462 + name = Release;
  463 + };
  464 + 036CBF4E1D3731260044A601 /* Debug */ = {
  465 + isa = XCBuildConfiguration;
  466 + buildSettings = {
  467 + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
  468 + INFOPLIST_FILE = WSWebImageDemo/Info.plist;
  469 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
  470 + PRODUCT_BUNDLE_IDENTIFIER = wangshuai.WSWebImageDemo;
  471 + PRODUCT_NAME = "$(TARGET_NAME)";
  472 + };
  473 + name = Debug;
  474 + };
  475 + 036CBF4F1D3731260044A601 /* Release */ = {
  476 + isa = XCBuildConfiguration;
  477 + buildSettings = {
  478 + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
  479 + INFOPLIST_FILE = WSWebImageDemo/Info.plist;
  480 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
  481 + PRODUCT_BUNDLE_IDENTIFIER = wangshuai.WSWebImageDemo;
  482 + PRODUCT_NAME = "$(TARGET_NAME)";
  483 + };
  484 + name = Release;
  485 + };
  486 + 036CBF511D3731260044A601 /* Debug */ = {
  487 + isa = XCBuildConfiguration;
  488 + buildSettings = {
  489 + BUNDLE_LOADER = "$(TEST_HOST)";
  490 + INFOPLIST_FILE = WSWebImageDemoTests/Info.plist;
  491 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  492 + PRODUCT_BUNDLE_IDENTIFIER = wangshuai.WSWebImageDemoTests;
  493 + PRODUCT_NAME = "$(TARGET_NAME)";
  494 + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WSWebImageDemo.app/WSWebImageDemo";
  495 + };
  496 + name = Debug;
  497 + };
  498 + 036CBF521D3731260044A601 /* Release */ = {
  499 + isa = XCBuildConfiguration;
  500 + buildSettings = {
  501 + BUNDLE_LOADER = "$(TEST_HOST)";
  502 + INFOPLIST_FILE = WSWebImageDemoTests/Info.plist;
  503 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  504 + PRODUCT_BUNDLE_IDENTIFIER = wangshuai.WSWebImageDemoTests;
  505 + PRODUCT_NAME = "$(TARGET_NAME)";
  506 + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WSWebImageDemo.app/WSWebImageDemo";
  507 + };
  508 + name = Release;
  509 + };
  510 + 036CBF541D3731260044A601 /* Debug */ = {
  511 + isa = XCBuildConfiguration;
  512 + buildSettings = {
  513 + INFOPLIST_FILE = WSWebImageDemoUITests/Info.plist;
  514 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  515 + PRODUCT_BUNDLE_IDENTIFIER = wangshuai.WSWebImageDemoUITests;
  516 + PRODUCT_NAME = "$(TARGET_NAME)";
  517 + TEST_TARGET_NAME = WSWebImageDemo;
  518 + };
  519 + name = Debug;
  520 + };
  521 + 036CBF551D3731260044A601 /* Release */ = {
  522 + isa = XCBuildConfiguration;
  523 + buildSettings = {
  524 + INFOPLIST_FILE = WSWebImageDemoUITests/Info.plist;
  525 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  526 + PRODUCT_BUNDLE_IDENTIFIER = wangshuai.WSWebImageDemoUITests;
  527 + PRODUCT_NAME = "$(TARGET_NAME)";
  528 + TEST_TARGET_NAME = WSWebImageDemo;
  529 + };
  530 + name = Release;
  531 + };
  532 +/* End XCBuildConfiguration section */
  533 +
  534 +/* Begin XCConfigurationList section */
  535 + 036CBF1B1D3731260044A601 /* Build configuration list for PBXProject "WSWebImageDemo" */ = {
  536 + isa = XCConfigurationList;
  537 + buildConfigurations = (
  538 + 036CBF4B1D3731260044A601 /* Debug */,
  539 + 036CBF4C1D3731260044A601 /* Release */,
  540 + );
  541 + defaultConfigurationIsVisible = 0;
  542 + defaultConfigurationName = Release;
  543 + };
  544 + 036CBF4D1D3731260044A601 /* Build configuration list for PBXNativeTarget "WSWebImageDemo" */ = {
  545 + isa = XCConfigurationList;
  546 + buildConfigurations = (
  547 + 036CBF4E1D3731260044A601 /* Debug */,
  548 + 036CBF4F1D3731260044A601 /* Release */,
  549 + );
  550 + defaultConfigurationIsVisible = 0;
  551 + defaultConfigurationName = Release;
  552 + };
  553 + 036CBF501D3731260044A601 /* Build configuration list for PBXNativeTarget "WSWebImageDemoTests" */ = {
  554 + isa = XCConfigurationList;
  555 + buildConfigurations = (
  556 + 036CBF511D3731260044A601 /* Debug */,
  557 + 036CBF521D3731260044A601 /* Release */,
  558 + );
  559 + defaultConfigurationIsVisible = 0;
  560 + defaultConfigurationName = Release;
  561 + };
  562 + 036CBF531D3731260044A601 /* Build configuration list for PBXNativeTarget "WSWebImageDemoUITests" */ = {
  563 + isa = XCConfigurationList;
  564 + buildConfigurations = (
  565 + 036CBF541D3731260044A601 /* Debug */,
  566 + 036CBF551D3731260044A601 /* Release */,
  567 + );
  568 + defaultConfigurationIsVisible = 0;
  569 + defaultConfigurationName = Release;
  570 + };
  571 +/* End XCConfigurationList section */
  572 + };
  573 + rootObject = 036CBF181D3731260044A601 /* Project object */;
  574 +}
... ...
WSWebImageDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Workspace
  3 + version = "1.0">
  4 + <FileRef
  5 + location = "self:WSWebImageDemo.xcodeproj">
  6 + </FileRef>
  7 +</Workspace>
... ...
WSWebImageDemo.xcodeproj/xcuserdata/wangshuai.xcuserdatad/xcschemes/WSWebImageDemo.xcscheme 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Scheme
  3 + LastUpgradeVersion = "0730"
  4 + version = "1.3">
  5 + <BuildAction
  6 + parallelizeBuildables = "YES"
  7 + buildImplicitDependencies = "YES">
  8 + <BuildActionEntries>
  9 + <BuildActionEntry
  10 + buildForTesting = "YES"
  11 + buildForRunning = "YES"
  12 + buildForProfiling = "YES"
  13 + buildForArchiving = "YES"
  14 + buildForAnalyzing = "YES">
  15 + <BuildableReference
  16 + BuildableIdentifier = "primary"
  17 + BlueprintIdentifier = "036CBF1F1D3731260044A601"
  18 + BuildableName = "WSWebImageDemo.app"
  19 + BlueprintName = "WSWebImageDemo"
  20 + ReferencedContainer = "container:WSWebImageDemo.xcodeproj">
  21 + </BuildableReference>
  22 + </BuildActionEntry>
  23 + </BuildActionEntries>
  24 + </BuildAction>
  25 + <TestAction
  26 + buildConfiguration = "Debug"
  27 + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
  28 + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
  29 + shouldUseLaunchSchemeArgsEnv = "YES">
  30 + <Testables>
  31 + <TestableReference
  32 + skipped = "NO">
  33 + <BuildableReference
  34 + BuildableIdentifier = "primary"
  35 + BlueprintIdentifier = "036CBF381D3731260044A601"
  36 + BuildableName = "WSWebImageDemoTests.xctest"
  37 + BlueprintName = "WSWebImageDemoTests"
  38 + ReferencedContainer = "container:WSWebImageDemo.xcodeproj">
  39 + </BuildableReference>
  40 + </TestableReference>
  41 + <TestableReference
  42 + skipped = "NO">
  43 + <BuildableReference
  44 + BuildableIdentifier = "primary"
  45 + BlueprintIdentifier = "036CBF431D3731260044A601"
  46 + BuildableName = "WSWebImageDemoUITests.xctest"
  47 + BlueprintName = "WSWebImageDemoUITests"
  48 + ReferencedContainer = "container:WSWebImageDemo.xcodeproj">
  49 + </BuildableReference>
  50 + </TestableReference>
  51 + </Testables>
  52 + <MacroExpansion>
  53 + <BuildableReference
  54 + BuildableIdentifier = "primary"
  55 + BlueprintIdentifier = "036CBF1F1D3731260044A601"
  56 + BuildableName = "WSWebImageDemo.app"
  57 + BlueprintName = "WSWebImageDemo"
  58 + ReferencedContainer = "container:WSWebImageDemo.xcodeproj">
  59 + </BuildableReference>
  60 + </MacroExpansion>
  61 + <AdditionalOptions>
  62 + </AdditionalOptions>
  63 + </TestAction>
  64 + <LaunchAction
  65 + buildConfiguration = "Debug"
  66 + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
  67 + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
  68 + launchStyle = "0"
  69 + useCustomWorkingDirectory = "NO"
  70 + ignoresPersistentStateOnLaunch = "NO"
  71 + debugDocumentVersioning = "YES"
  72 + debugServiceExtension = "internal"
  73 + allowLocationSimulation = "YES">
  74 + <BuildableProductRunnable
  75 + runnableDebuggingMode = "0">
  76 + <BuildableReference
  77 + BuildableIdentifier = "primary"
  78 + BlueprintIdentifier = "036CBF1F1D3731260044A601"
  79 + BuildableName = "WSWebImageDemo.app"
  80 + BlueprintName = "WSWebImageDemo"
  81 + ReferencedContainer = "container:WSWebImageDemo.xcodeproj">
  82 + </BuildableReference>
  83 + </BuildableProductRunnable>
  84 + <AdditionalOptions>
  85 + </AdditionalOptions>
  86 + </LaunchAction>
  87 + <ProfileAction
  88 + buildConfiguration = "Release"
  89 + shouldUseLaunchSchemeArgsEnv = "YES"
  90 + savedToolIdentifier = ""
  91 + useCustomWorkingDirectory = "NO"
  92 + debugDocumentVersioning = "YES">
  93 + <BuildableProductRunnable
  94 + runnableDebuggingMode = "0">
  95 + <BuildableReference
  96 + BuildableIdentifier = "primary"
  97 + BlueprintIdentifier = "036CBF1F1D3731260044A601"
  98 + BuildableName = "WSWebImageDemo.app"
  99 + BlueprintName = "WSWebImageDemo"
  100 + ReferencedContainer = "container:WSWebImageDemo.xcodeproj">
  101 + </BuildableReference>
  102 + </BuildableProductRunnable>
  103 + </ProfileAction>
  104 + <AnalyzeAction
  105 + buildConfiguration = "Debug">
  106 + </AnalyzeAction>
  107 + <ArchiveAction
  108 + buildConfiguration = "Release"
  109 + revealArchiveInOrganizer = "YES">
  110 + </ArchiveAction>
  111 +</Scheme>
... ...
WSWebImageDemo.xcodeproj/xcuserdata/wangshuai.xcuserdatad/xcschemes/xcschememanagement.plist 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>SchemeUserState</key>
  6 + <dict>
  7 + <key>WSWebImageDemo.xcscheme</key>
  8 + <dict>
  9 + <key>orderHint</key>
  10 + <integer>0</integer>
  11 + </dict>
  12 + </dict>
  13 + <key>SuppressBuildableAutocreation</key>
  14 + <dict>
  15 + <key>036CBF1F1D3731260044A601</key>
  16 + <dict>
  17 + <key>primary</key>
  18 + <true/>
  19 + </dict>
  20 + <key>036CBF381D3731260044A601</key>
  21 + <dict>
  22 + <key>primary</key>
  23 + <true/>
  24 + </dict>
  25 + <key>036CBF431D3731260044A601</key>
  26 + <dict>
  27 + <key>primary</key>
  28 + <true/>
  29 + </dict>
  30 + </dict>
  31 +</dict>
  32 +</plist>
... ...
WSWebImageDemo/AppDelegate.h 0 → 100644
  1 +//
  2 +// AppDelegate.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface AppDelegate : UIResponder <UIApplicationDelegate>
  12 +
  13 +@property (strong, nonatomic) UIWindow *window;
  14 +
  15 +
  16 +@end
  17 +
... ...
WSWebImageDemo/AppDelegate.m 0 → 100644
  1 +//
  2 +// AppDelegate.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "AppDelegate.h"
  10 +
  11 +@interface AppDelegate ()
  12 +
  13 +@end
  14 +
  15 +@implementation AppDelegate
  16 +
  17 +
  18 +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  19 + // Override point for customization after application launch.
  20 + return YES;
  21 +}
  22 +
  23 +- (void)applicationWillResignActive:(UIApplication *)application {
  24 + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  25 + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
  26 +}
  27 +
  28 +- (void)applicationDidEnterBackground:(UIApplication *)application {
  29 + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  30 + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  31 +}
  32 +
  33 +- (void)applicationWillEnterForeground:(UIApplication *)application {
  34 + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
  35 +}
  36 +
  37 +- (void)applicationDidBecomeActive:(UIApplication *)application {
  38 + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
  39 +}
  40 +
  41 +- (void)applicationWillTerminate:(UIApplication *)application {
  42 + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  43 +}
  44 +
  45 +@end
... ...
WSWebImageDemo/Assets.xcassets/AppIcon.appiconset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "iphone",
  5 + "size" : "29x29",
  6 + "scale" : "2x"
  7 + },
  8 + {
  9 + "idiom" : "iphone",
  10 + "size" : "29x29",
  11 + "scale" : "3x"
  12 + },
  13 + {
  14 + "idiom" : "iphone",
  15 + "size" : "40x40",
  16 + "scale" : "2x"
  17 + },
  18 + {
  19 + "idiom" : "iphone",
  20 + "size" : "40x40",
  21 + "scale" : "3x"
  22 + },
  23 + {
  24 + "idiom" : "iphone",
  25 + "size" : "60x60",
  26 + "scale" : "2x"
  27 + },
  28 + {
  29 + "idiom" : "iphone",
  30 + "size" : "60x60",
  31 + "scale" : "3x"
  32 + },
  33 + {
  34 + "idiom" : "ipad",
  35 + "size" : "29x29",
  36 + "scale" : "1x"
  37 + },
  38 + {
  39 + "idiom" : "ipad",
  40 + "size" : "29x29",
  41 + "scale" : "2x"
  42 + },
  43 + {
  44 + "idiom" : "ipad",
  45 + "size" : "40x40",
  46 + "scale" : "1x"
  47 + },
  48 + {
  49 + "idiom" : "ipad",
  50 + "size" : "40x40",
  51 + "scale" : "2x"
  52 + },
  53 + {
  54 + "idiom" : "ipad",
  55 + "size" : "76x76",
  56 + "scale" : "1x"
  57 + },
  58 + {
  59 + "idiom" : "ipad",
  60 + "size" : "76x76",
  61 + "scale" : "2x"
  62 + },
  63 + {
  64 + "idiom" : "ipad",
  65 + "size" : "83.5x83.5",
  66 + "scale" : "2x"
  67 + }
  68 + ],
  69 + "info" : {
  70 + "version" : 1,
  71 + "author" : "xcode"
  72 + }
  73 +}
0 74 \ No newline at end of file
... ...
WSWebImageDemo/Base.lproj/LaunchScreen.storyboard 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
  3 + <dependencies>
  4 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
  5 + </dependencies>
  6 + <scenes>
  7 + <!--View Controller-->
  8 + <scene sceneID="EHf-IW-A2E">
  9 + <objects>
  10 + <viewController id="01J-lp-oVM" sceneMemberID="viewController">
  11 + <layoutGuides>
  12 + <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
  13 + <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
  14 + </layoutGuides>
  15 + <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
  16 + <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
  17 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  18 + <animations/>
  19 + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
  20 + </view>
  21 + </viewController>
  22 + <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
  23 + </objects>
  24 + <point key="canvasLocation" x="53" y="375"/>
  25 + </scene>
  26 + </scenes>
  27 +</document>
... ...
WSWebImageDemo/Base.lproj/Main.storyboard 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
  3 + <dependencies>
  4 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
  5 + </dependencies>
  6 + <scenes>
  7 + <!--View Controller-->
  8 + <scene sceneID="tne-QT-ifu">
  9 + <objects>
  10 + <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
  11 + <layoutGuides>
  12 + <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
  13 + <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
  14 + </layoutGuides>
  15 + <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
  16 + <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
  17 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  18 + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
  19 + </view>
  20 + </viewController>
  21 + <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
  22 + </objects>
  23 + </scene>
  24 + </scenes>
  25 +</document>
... ...
WSWebImageDemo/CNLiveImageCache.h 0 → 100644
  1 +//
  2 +// CNLiveImageCache.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/19.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import <UIKit/UIKit.h>
  11 +#import "CNLiveWebImageBlock.h"
  12 +
  13 +//typedef void(^CNLiveWebImageQueryCompletedBlock)(UIImage *image, CNLiveImageCacheType type);
  14 +typedef void(^CNLiveCompletedBlock)();
  15 +
  16 +@interface CNLiveImageCache : NSObject
  17 +
  18 ++ (CNLiveImageCache *)sharedImageCache;
  19 +
  20 +- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk;
  21 +
  22 +- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key;
  23 +
  24 +- (UIImage *)imageFromDiskCacheForKey:(NSString *)key;
  25 +
  26 +- (BOOL)queryDiskCacheForKey:(NSString *)key done:(CNLiveWebImageQueryCompletedBlock)doneBlock;
  27 +
  28 +- (void)removeCacheForKey:(NSString *)key done:(CNLiveCompletedBlock)completed;
  29 +
  30 +- (long long)diskCacheSize;
  31 +
  32 +- (void)clearMemory;
  33 +
  34 +- (void)clearDisk;
  35 +
  36 +@end
... ...
WSWebImageDemo/CNLiveImageCache.m 0 → 100644
  1 +//
  2 +// CNLiveImageCache.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/19.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveImageCache.h"
  10 +#import <CommonCrypto/CommonDigest.h>
  11 +#import "UIImage+MultiFormat.h"
  12 +
  13 +FOUNDATION_STATIC_INLINE NSUInteger CNLiveCacheCostForImage(UIImage *image) {
  14 + return image.size.height * image.size.width * image.scale * image.scale;
  15 +}
  16 +
  17 +typedef void(^CNLiveWebImageNoParamsBlock)();
  18 +
  19 +@interface CNLiveImageCache ()
  20 +
  21 +@property (nonatomic, strong) NSCache *memoryCache;
  22 +@property (nonatomic, copy) NSString *diskCachePath;
  23 +@property (nonatomic, strong) dispatch_queue_t ioQueue;
  24 +
  25 +@end
  26 +
  27 +@implementation CNLiveImageCache
  28 +{
  29 + NSFileManager *_fileManager;
  30 +}
  31 +
  32 ++ (CNLiveImageCache *)sharedImageCache
  33 +{
  34 + static dispatch_once_t onceToken;
  35 + static id instance;
  36 + dispatch_once(&onceToken, ^{
  37 + instance = [self new];
  38 + });
  39 + return instance;
  40 +}
  41 +
  42 +- (id)init {
  43 + return [self initWithNamespace:@"default"];
  44 +}
  45 +
  46 +- (id)initWithNamespace:(NSString *)ns {
  47 + NSString *path = [self makeDiskCachePath:ns];
  48 + return [self initWithNamespace:ns diskCacheDirectory:path];
  49 +}
  50 +
  51 +- (NSString *)makeDiskCachePath:(NSString *)fullNamespace {
  52 + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
  53 + return [paths[0] stringByAppendingString:fullNamespace];
  54 +}
  55 +
  56 +- (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory {
  57 + if (self = [super init]) {
  58 + NSString *fullNameSpace = [@"com.cnlive.CNLiveImageCache." stringByAppendingString:ns];
  59 + _ioQueue = dispatch_queue_create("com.cnlive.CNLiveImageCacheQueue", DISPATCH_QUEUE_SERIAL);
  60 + _memoryCache = [[NSCache alloc] init];
  61 + _memoryCache.name = fullNameSpace;
  62 +
  63 + if (directory != nil) {
  64 + _diskCachePath = [directory stringByAppendingPathComponent:fullNameSpace];
  65 + }
  66 + else {
  67 + _diskCachePath = [[self makeDiskCachePath:ns] stringByAppendingPathComponent:fullNameSpace];
  68 + }
  69 +
  70 + dispatch_sync(_ioQueue, ^{
  71 + _fileManager = [NSFileManager new];
  72 + });
  73 +
  74 + [[NSNotificationCenter defaultCenter] addObserver:self
  75 + selector:@selector(clearMemory)
  76 + name:UIApplicationDidReceiveMemoryWarningNotification
  77 + object:nil];
  78 +
  79 +// [[NSNotificationCenter defaultCenter] addObserver:self
  80 +// selector:@selector(clearDisk)
  81 +// name:UIApplicationWillTerminateNotification
  82 +// object:nil];
  83 + }
  84 + return self;
  85 +}
  86 +
  87 +- (void)dealloc
  88 +{
  89 + [[NSNotificationCenter defaultCenter] removeObserver:self];
  90 +}
  91 +
  92 +- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk
  93 +{
  94 + if (!image || !key) {
  95 + return;
  96 + }
  97 +
  98 + NSUInteger cost = CNLiveCacheCostForImage(image);
  99 + [_memoryCache setObject:image forKey:key cost:cost];
  100 +
  101 + if (toDisk) {
  102 + dispatch_async(_ioQueue, ^{
  103 + NSData *data = UIImageJPEGRepresentation(image, 1.0);
  104 +
  105 + if (data) {
  106 + if (![_fileManager fileExistsAtPath:_diskCachePath]) {
  107 + [_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL];
  108 + }
  109 + NSString *cachePathForKey = [self defaultCachePathForKey:key];
  110 + [_fileManager createFileAtPath:cachePathForKey contents:data attributes:nil];
  111 + }
  112 + });
  113 + }
  114 +}
  115 +
  116 +- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key
  117 +{
  118 + return [self.memoryCache objectForKey:key];
  119 +}
  120 +
  121 +- (UIImage *)imageFromDiskCacheForKey:(NSString *)key
  122 +{
  123 + UIImage *memoryImage = [self imageFromMemoryCacheForKey:key];
  124 + if (memoryImage) {
  125 + return memoryImage;
  126 + }
  127 +
  128 + NSData *diskData = [self getDiskImageDataWithKey:key];
  129 + if (diskData) {
  130 + return [UIImage ws_imageWithData:diskData];
  131 + }
  132 +
  133 + return nil;
  134 +}
  135 +
  136 +- (BOOL)queryDiskCacheForKey:(NSString *)key done:(CNLiveWebImageQueryCompletedBlock)doneBlock
  137 +{
  138 + if (!doneBlock) {
  139 + return NO;
  140 + }
  141 + if (!key) {
  142 + doneBlock(nil, CNLiveImageCacheTypeNone);
  143 + return NO;
  144 + }
  145 +
  146 + UIImage *memoryImage = [self imageFromMemoryCacheForKey:key];
  147 + if (memoryImage) {
  148 + doneBlock(memoryImage, CNLiveImageCacheTypeMemory);
  149 + return YES;
  150 + }
  151 +
  152 + UIImage *diskImage = [self imageFromDiskCacheForKey:key];
  153 + if (diskImage) {
  154 + doneBlock(diskImage, CNLiveImageCacheTypeDisk);
  155 + return YES;
  156 + }
  157 +
  158 + doneBlock(nil, CNLiveImageCacheTypeNone);
  159 + return NO;
  160 +
  161 +}
  162 +
  163 +- (void)removeCacheForKey:(NSString *)key done:(CNLiveCompletedBlock)completed
  164 +{
  165 + if (!key || !completed) {
  166 + return;
  167 + }
  168 +
  169 + if ([self imageFromMemoryCacheForKey:key]) {
  170 + [self.memoryCache removeObjectForKey:key];
  171 + }
  172 +
  173 + if ([self imageFromDiskCacheForKey:key]) {
  174 + NSString *cachePathForKey = [self defaultCachePathForKey:key];
  175 + [_fileManager removeItemAtPath:cachePathForKey error:nil];
  176 + }
  177 +
  178 + completed();
  179 +}
  180 +
  181 +- (long long)diskCacheSize
  182 +{
  183 + if ([_fileManager fileExistsAtPath:self.diskCachePath]) {
  184 + NSArray *subPathArray = [_fileManager subpathsAtPath:self.diskCachePath];
  185 + if (subPathArray && subPathArray.count > 0) {
  186 + long long totalCacheSize = 0;
  187 + for (NSString *subPath in subPathArray) {
  188 + NSString *fullPath = [self.diskCachePath stringByAppendingPathComponent:subPath];
  189 + NSDictionary *cacheSizeDic = [_fileManager attributesOfItemAtPath:fullPath error:nil];
  190 + totalCacheSize += [cacheSizeDic fileSize];
  191 + }
  192 + return totalCacheSize;
  193 + }
  194 + }
  195 + return 0;
  196 +}
  197 +
  198 +- (void)clearMemory
  199 +{
  200 + [self.memoryCache removeAllObjects];
  201 +}
  202 +
  203 +- (void)clearDisk
  204 +{
  205 + [self clearDiskOnCompletion:nil];
  206 +}
  207 +
  208 +- (void)clearDiskOnCompletion:(CNLiveWebImageNoParamsBlock)completion
  209 +{
  210 + dispatch_async(self.ioQueue, ^{
  211 + [_fileManager removeItemAtPath:self.diskCachePath error:nil];
  212 + [_fileManager createDirectoryAtPath:self.diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL];
  213 +
  214 + if (completion) {
  215 + dispatch_async(dispatch_get_main_queue(), ^{
  216 + completion();
  217 + });
  218 + }
  219 + });
  220 +}
  221 +
  222 +#pragma mark <PrivateMethod>
  223 +- (NSData *)getDiskImageDataWithKey:(NSString *)key
  224 +{
  225 + NSString *filePath = [self defaultCachePathForKey:key];
  226 + NSData *imageData = [NSData dataWithContentsOfFile:filePath];
  227 + return imageData;
  228 +}
  229 +
  230 +- (NSString *)defaultCachePathForKey:(NSString *)key
  231 +{
  232 + return [self cachePathForKey:key inPath:self.diskCachePath];
  233 +}
  234 +
  235 +- (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path
  236 +{
  237 + NSString *fileName = [self cachedFileNameForKey:key];
  238 + return [path stringByAppendingPathComponent:fileName];
  239 +}
  240 +
  241 +- (NSString *)cachedFileNameForKey:(NSString *)key {
  242 + const char *str = [key UTF8String];
  243 + if (str == NULL) {
  244 + str = "";
  245 + }
  246 + unsigned char r[CC_MD5_DIGEST_LENGTH];
  247 + CC_MD5(str, (CC_LONG)strlen(str), r);
  248 + NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
  249 + r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15]];
  250 +
  251 + return filename;
  252 +}
  253 +
  254 +@end
... ...
WSWebImageDemo/CNLiveWebImageBlock.h 0 → 100644
  1 +//
  2 +// CNLiveWebImageBlock.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/27.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#ifndef CNLiveWebImageBlock_h
  10 +#define CNLiveWebImageBlock_h
  11 +
  12 +typedef NS_ENUM(NSUInteger, CNLiveImageCacheType) {
  13 + CNLiveImageCacheTypeNone,
  14 + CNLiveImageCacheTypeMemory,
  15 + CNLiveImageCacheTypeDisk
  16 +};
  17 +
  18 +typedef void(^CNLiveDownloadProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
  19 +typedef void(^CNLiveDownloadCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished);
  20 +
  21 +typedef void(^CNLiveWebImageQueryCompletedBlock)(UIImage *image, CNLiveImageCacheType type);
  22 +typedef void(^CNLiveCompletedBlock)();
  23 +typedef void(^CNLiveWebImageNoParamsBlock)();
  24 +
  25 +#endif /* CNLiveWebImageBlock_h */
... ...
WSWebImageDemo/CNLiveWebImageDownload.h 0 → 100644
  1 +//
  2 +// CNLiveWebImageDownload.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import <UIKit/UIKit.h>
  11 +#import "CNLiveWebImageOperation.h"
  12 +#import "CNLiveWebImageBlock.h"
  13 +
  14 +typedef NS_OPTIONS(NSUInteger, CNLiveWebImageDownloadOptions) {
  15 + CNLiveWebImageDownloadProgressiveDownload = 1 << 0,
  16 + CNLiveWebImageDownloadContinueInBackground = 1 << 1
  17 +};
  18 +
  19 +@interface CNLiveWebImageDownload : NSObject
  20 +
  21 ++ (CNLiveWebImageDownload *)sharedDownload;
  22 +
  23 +- (id <CNLiveWebImageOperation>)downloadWebImageWithURL:(NSURL *)url options:(CNLiveWebImageDownloadOptions)options progress:(CNLiveDownloadProgressBlock)progress completed:(CNLiveDownloadCompletedBlock)completed;
  24 +
  25 +@end
... ...
WSWebImageDemo/CNLiveWebImageDownload.m 0 → 100644
  1 +//
  2 +// CNLiveWebImageDownload.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveWebImageDownload.h"
  10 +#import "CNLiveWebImageDownloadOperation.h"
  11 +
  12 +@interface CNLiveWebImageDownload ()
  13 +
  14 +@property (nonatomic, strong) NSOperationQueue *downloadQueue;
  15 +
  16 +@end
  17 +
  18 +@implementation CNLiveWebImageDownload
  19 +
  20 ++ (CNLiveWebImageDownload *)sharedDownload
  21 +{
  22 + static dispatch_once_t once;
  23 + static id instance;
  24 + dispatch_once(&once, ^{
  25 + instance = [self new];
  26 + });
  27 + return instance;
  28 +}
  29 +
  30 +- (instancetype)init
  31 +{
  32 + if ((self = [super init])) {
  33 + _downloadQueue = [NSOperationQueue new];
  34 + _downloadQueue.maxConcurrentOperationCount = 6;
  35 + }
  36 + return self;
  37 +}
  38 +
  39 +- (void)dealloc
  40 +{
  41 + [self.downloadQueue cancelAllOperations];
  42 +}
  43 +
  44 +- (id<CNLiveWebImageOperation>)downloadWebImageWithURL:(NSURL *)url options:(CNLiveWebImageDownloadOptions)options progress:(CNLiveDownloadProgressBlock)progress completed:(CNLiveDownloadCompletedBlock)completed
  45 +{
  46 + CNLiveWebImageDownloadOperation *operation;
  47 + operation = [[CNLiveWebImageDownloadOperation alloc] initWithURL:url
  48 + options:options
  49 + progress:progress
  50 + completed:completed];
  51 + [self.downloadQueue addOperation:operation];
  52 + return (id <CNLiveWebImageOperation>)operation;
  53 +}
  54 +@end
... ...
WSWebImageDemo/CNLiveWebImageDownloadOperation.h 0 → 100644
  1 +//
  2 +// CNLiveWebImageDownloadOperation.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/25.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import "CNLiveWebImageDownload.h"
  11 +#import "CNLiveWebImageBlock.h"
  12 +
  13 +@interface CNLiveWebImageDownloadOperation : NSOperation
  14 +
  15 +- (id)initWithURL:(NSURL *)url options:(CNLiveWebImageDownloadOptions)options progress:(CNLiveDownloadProgressBlock)progress completed:(CNLiveDownloadCompletedBlock)completed;
  16 +
  17 +@end
... ...
WSWebImageDemo/CNLiveWebImageDownloadOperation.m 0 → 100644
  1 +//
  2 +// CNLiveWebImageDownloadOperation.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/25.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveWebImageDownloadOperation.h"
  10 +#import "CNLiveWebImageOperation.h"
  11 +#import <ImageIO/ImageIO.h>
  12 +#import "UIImage+MultiFormat.h"
  13 +
  14 +#define CNLiveWebImageBackgroundSessionIdentifier @"CNLiveWebImageBackgroundSessionIdentifier"
  15 +
  16 +@interface CNLiveWebImageDownloadOperation ()<CNLiveWebImageOperation, NSURLSessionDataDelegate, NSURLSessionTaskDelegate, NSURLSessionDelegate>
  17 +
  18 +@property (nonatomic, copy) CNLiveDownloadProgressBlock progressBlock;
  19 +@property (nonatomic, copy) CNLiveDownloadCompletedBlock completedBlock;
  20 +@property (nonatomic, assign) CNLiveWebImageDownloadOptions options;
  21 +@property (nonatomic, strong) NSURL *url;
  22 +
  23 +@property (nonatomic, strong) NSURLSessionConfiguration *config;
  24 +@property (nonatomic, strong) NSURLSession *session;
  25 +@property (nonatomic, strong) NSURLSessionDataTask *dataTask;
  26 +@property (nonatomic, assign) NSInteger expectedSize;
  27 +@property (nonatomic, strong) NSMutableData *imageData;
  28 +@property (nonatomic, strong) NSURLResponse *response;
  29 +
  30 +@end
  31 +
  32 +@implementation CNLiveWebImageDownloadOperation
  33 +
  34 +- (id)initWithURL:(NSURL *)url options:(CNLiveWebImageDownloadOptions)options progress:(CNLiveDownloadProgressBlock)progress completed:(CNLiveDownloadCompletedBlock)completed
  35 +{
  36 + if ((self = [super init])) {
  37 + _url = url;
  38 + _progressBlock = progress;
  39 + _completedBlock = completed;
  40 + _options = options;
  41 + }
  42 + return self;
  43 +}
  44 +
  45 +- (void)start
  46 +{
  47 + @synchronized (self) {
  48 + if (self.isCancelled) {
  49 + return;
  50 + }
  51 + }
  52 + self.dataTask = [self.session dataTaskWithURL:self.url];
  53 + [self.dataTask resume];
  54 + [self.session finishTasksAndInvalidate];
  55 +}
  56 +
  57 +- (NSURLSessionConfiguration *)config
  58 +{
  59 + if (!_config) {
  60 + if (self.options & CNLiveWebImageDownloadContinueInBackground) {
  61 + _config = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:CNLiveWebImageBackgroundSessionIdentifier];
  62 + }
  63 + else {
  64 + _config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
  65 + }
  66 + }
  67 + return _config;
  68 +}
  69 +
  70 +- (NSURLSession *)session
  71 +{
  72 + if (!_session) {
  73 + _session = [NSURLSession sessionWithConfiguration:self.config delegate:self delegateQueue:[NSOperationQueue mainQueue]];
  74 + }
  75 + return _session;
  76 +}
  77 +
  78 +#pragma mark <NSURLSessionDataDelegate>
  79 +- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler
  80 +{
  81 + if (![response respondsToSelector:@selector(statusCode)] || ([((NSHTTPURLResponse *)response) statusCode] < 400 && [((NSHTTPURLResponse *)response) statusCode] != 304)) {
  82 + NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0;
  83 + self.expectedSize = expected;
  84 + if (self.progressBlock) {
  85 + self.progressBlock(0, expected);
  86 + }
  87 +
  88 + self.imageData = [[NSMutableData alloc] initWithCapacity:expected];
  89 + self.response = response;
  90 + completionHandler(NSURLSessionResponseAllow);
  91 + }
  92 + else {
  93 +
  94 + [self.dataTask cancel];
  95 +
  96 + dispatch_async(dispatch_get_main_queue(), ^{
  97 + if (self.completedBlock) {
  98 + self.completedBlock(nil, nil, [NSError errorWithDomain:NSURLErrorDomain code:[((NSHTTPURLResponse *)response) statusCode] userInfo:nil], YES);
  99 + }
  100 + });
  101 + }
  102 +}
  103 +
  104 +- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data
  105 +{
  106 + [self.imageData appendData:data];
  107 + if (self.options & CNLiveWebImageDownloadProgressiveDownload && self.completedBlock) {
  108 + const NSInteger totalSize = self.imageData.length;
  109 + CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)self.imageData, NULL);
  110 + if (totalSize < self.expectedSize) {
  111 + CGImageRef partialImageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);
  112 + if (partialImageRef) {
  113 + UIImage *image = [UIImage imageWithCGImage:partialImageRef];
  114 + CGImageRelease(partialImageRef);
  115 + dispatch_async(dispatch_get_main_queue(), ^{
  116 + if (self.completedBlock) {
  117 + self.completedBlock(image, self.imageData, nil, NO);
  118 + }
  119 + });
  120 + }
  121 + }
  122 +
  123 + CFRelease(imageSource);
  124 + }
  125 +
  126 + dispatch_async(dispatch_get_main_queue(), ^{
  127 + if (self.progressBlock) {
  128 + self.progressBlock(self.imageData.length, self.expectedSize);
  129 + }
  130 + });
  131 +}
  132 +
  133 +- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
  134 +{
  135 + if (error) {
  136 + dispatch_async(dispatch_get_main_queue(), ^{
  137 + if (self.completedBlock) {
  138 + self.completedBlock(nil, nil, error, NO);
  139 + }
  140 + });
  141 + }
  142 + else {
  143 + dispatch_async(dispatch_get_main_queue(), ^{
  144 + if (self.completedBlock) {
  145 + self.completedBlock([UIImage ws_imageWithData:self.imageData], self.imageData, nil, YES);
  146 + }
  147 + });
  148 + }
  149 +}
  150 +
  151 +- (void)cancel
  152 +{
  153 + if (self.session) {
  154 + [self.session invalidateAndCancel];
  155 + }
  156 + self.completedBlock = nil;
  157 + self.progressBlock = nil;
  158 + self.session = nil;
  159 + self.imageData = nil;
  160 +}
  161 +
  162 +
  163 +
  164 +
  165 +
  166 +
  167 +
  168 +
  169 +
  170 +
  171 +
  172 +
  173 +
  174 +
  175 +@end
... ...
WSWebImageDemo/CNLiveWebImageManager.h 0 → 100644
  1 +//
  2 +// CNLiveWebImageManager.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/27.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import <UIKit/UIKit.h>
  11 +#import "CNLiveWebImageBlock.h"
  12 +#import "CNLiveWebImageOperation.h"
  13 +
  14 +typedef NS_OPTIONS(NSUInteger, CNLiveWebImageOptions) {
  15 + CNLiveWebImageRetryFailed = 1 << 0,
  16 + CNLiveWebImageCacheMemoryOnly = 1 << 1,
  17 + CNLiveWebImageProgressiveDownload = 1 << 2,
  18 + CNLiveWebImageContinueInBackground = 1 << 3
  19 +};
  20 +
  21 +@interface CNLiveWebImageManager : NSObject
  22 +
  23 ++ (nonnull id)sharedManager;
  24 +
  25 +- (nonnull id <CNLiveWebImageOperation>)downloadWebImageWithURL:(nonnull NSURL *)url options:(CNLiveWebImageOptions)options progress:(nonnull CNLiveDownloadProgressBlock)progress completed:(nonnull CNLiveDownloadCompletedBlock)completed;
  26 +
  27 +- (void)storeImage:(nonnull UIImage *)image imageUrl:(nonnull NSURL *)url toDisk:(BOOL)toDisk;
  28 +
  29 +- (nullable UIImage *)imageFromMemoryCacheWithImageUrl:(nonnull NSURL *)url;
  30 +
  31 +- (nullable UIImage *)imageFromDiskCacheWithImageUrl:(nonnull NSURL *)url;
  32 +
  33 +- (BOOL)queryDiskCacheWithImageUrl:(nonnull NSURL *)url done:(nonnull CNLiveWebImageQueryCompletedBlock)doneBlock;
  34 +
  35 +- (void)removeCacheWithUrl:(nonnull NSURL *)url done:(nonnull CNLiveCompletedBlock)completed;
  36 +
  37 +- (long long)diskCacheSize;
  38 +
  39 +- (void)clearMemory;
  40 +
  41 +- (void)clearDisk;
  42 +
  43 +@end
... ...
WSWebImageDemo/CNLiveWebImageManager.m 0 → 100644
  1 +//
  2 +// CNLiveWebImageManager.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/27.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveWebImageManager.h"
  10 +#import "CNLiveWebImageDownload.h"
  11 +#import "CNLiveImageCache.h"
  12 +
  13 +@interface CNLiveWebImageManager ()
  14 +
  15 +@property (nonatomic, strong) CNLiveImageCache *imageCache;
  16 +@property (nonatomic, strong) NSMutableSet *failedURLs;
  17 +
  18 +@end
  19 +
  20 +@implementation CNLiveWebImageManager
  21 +
  22 ++ (id)sharedManager
  23 +{
  24 + static id manager;
  25 + static dispatch_once_t once;
  26 + dispatch_once(&once, ^{
  27 + manager = [self new];
  28 + });
  29 + return manager;
  30 +}
  31 +
  32 +- (instancetype)init
  33 +{
  34 + if ((self = [super init])) {
  35 + _imageCache = [CNLiveImageCache sharedImageCache];
  36 + _failedURLs = [NSMutableSet new];
  37 + }
  38 + return self;
  39 +}
  40 +
  41 +- (id<CNLiveWebImageOperation>)downloadWebImageWithURL:(NSURL *)url options:(CNLiveWebImageOptions)options progress:(CNLiveDownloadProgressBlock)progress completed:(CNLiveDownloadCompletedBlock)completed
  42 +{
  43 + if ([url isKindOfClass:NSString.class]) {
  44 + url = [NSURL URLWithString:(NSString *)url];
  45 + }
  46 + if (![url isKindOfClass:NSURL.class]) {
  47 + url = nil;
  48 + }
  49 +
  50 + BOOL isFailedUrl = NO;
  51 + @synchronized (self.failedURLs) {
  52 + isFailedUrl = [self.failedURLs containsObject:url];
  53 + }
  54 + if (!url || (!(options & CNLiveWebImageRetryFailed) && isFailedUrl)) {
  55 + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil];
  56 + completed(nil, nil, error, YES);
  57 + }
  58 +
  59 + BOOL hasCacheImage = [self.imageCache queryDiskCacheForKey:url.absoluteString done:^(UIImage *image, CNLiveImageCacheType type) {
  60 + if (image) {
  61 + completed(image,UIImageJPEGRepresentation(image, 1.0), nil, YES);
  62 + }
  63 + }];;
  64 +
  65 + if (hasCacheImage) {
  66 + return nil;
  67 + }
  68 +
  69 +
  70 + CNLiveWebImageDownloadOptions downloadOptions = 0;
  71 + if (options & CNLiveWebImageProgressiveDownload) downloadOptions |= CNLiveWebImageDownloadProgressiveDownload;
  72 + if (options & CNLiveWebImageContinueInBackground) downloadOptions |= CNLiveWebImageDownloadContinueInBackground;
  73 + id <CNLiveWebImageOperation> operation = [[CNLiveWebImageDownload sharedDownload] downloadWebImageWithURL:url options:downloadOptions progress:progress completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
  74 + if (error) {
  75 + BOOL shouldBeFailedURLAlliOSVersion = (error.code != NSURLErrorNotConnectedToInternet && error.code != NSURLErrorCancelled && error.code != NSURLErrorTimedOut);
  76 + BOOL shouldBeFailedURLiOS7 = (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1 && error.code != NSURLErrorInternationalRoamingOff && error.code != NSURLErrorCallIsActive && error.code != NSURLErrorDataNotAllowed);
  77 + if (shouldBeFailedURLAlliOSVersion || shouldBeFailedURLiOS7) {
  78 + @synchronized (self.failedURLs) {
  79 + [self.failedURLs addObject:url];
  80 + }
  81 + }
  82 + }
  83 + else {
  84 + if ((options & CNLiveWebImageRetryFailed)) {
  85 + @synchronized (self.failedURLs) {
  86 + [self.failedURLs removeObject:url];
  87 + }
  88 + }
  89 +
  90 + BOOL cacheOnDisk = !(options & CNLiveWebImageCacheMemoryOnly);
  91 + if (image && finished) {
  92 + if (cacheOnDisk) {
  93 + [self.imageCache storeImage:image forKey:[url absoluteString] toDisk:YES];
  94 + }
  95 + else {
  96 + [self.imageCache storeImage:image forKey:[url absoluteString] toDisk:NO];
  97 + }
  98 + }
  99 +
  100 + completed(image, data, error, finished);
  101 + }
  102 +
  103 + }];
  104 + return operation;
  105 +}
  106 +
  107 +- (void)storeImage:(UIImage *)image imageUrl:(NSURL *)url toDisk:(BOOL)toDisk
  108 +{
  109 + [self.imageCache storeImage:image forKey:url.absoluteString toDisk:toDisk];
  110 +}
  111 +
  112 +- (UIImage *)imageFromMemoryCacheWithImageUrl:(NSURL *)url
  113 +{
  114 + return [self.imageCache imageFromMemoryCacheForKey:url.absoluteString];
  115 +}
  116 +
  117 +- (UIImage *)imageFromDiskCacheWithImageUrl:(NSURL *)url
  118 +{
  119 + return [self.imageCache imageFromDiskCacheForKey:url.absoluteString];
  120 +}
  121 +
  122 +- (BOOL)queryDiskCacheWithImageUrl:(NSURL *)url done:(CNLiveWebImageQueryCompletedBlock)doneBlock
  123 +{
  124 + return [self.imageCache queryDiskCacheForKey:url.absoluteString done:doneBlock];
  125 +}
  126 +
  127 +- (void)removeCacheWithUrl:(NSURL *)url done:(CNLiveCompletedBlock)completed
  128 +{
  129 + [self.imageCache removeCacheForKey:url.absoluteString done:completed];
  130 +}
  131 +
  132 +- (long long)diskCacheSize
  133 +{
  134 + return [self.imageCache diskCacheSize];
  135 +}
  136 +
  137 +- (void)clearMemory
  138 +{
  139 + [self.imageCache clearMemory];
  140 +}
  141 +
  142 +- (void)clearDisk
  143 +{
  144 + [self.imageCache clearDisk];
  145 +}
  146 +
  147 +@end
... ...
WSWebImageDemo/CNLiveWebImageOperation.h 0 → 100644
  1 +//
  2 +// CNLiveWebImageOperation.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/19.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@protocol CNLiveWebImageOperation <NSObject>
  12 +
  13 +- (void)cancel;
  14 +
  15 +@end
... ...
WSWebImageDemo/Info.plist 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>CFBundleDevelopmentRegion</key>
  6 + <string>en</string>
  7 + <key>CFBundleExecutable</key>
  8 + <string>$(EXECUTABLE_NAME)</string>
  9 + <key>CFBundleIdentifier</key>
  10 + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
  11 + <key>CFBundleInfoDictionaryVersion</key>
  12 + <string>6.0</string>
  13 + <key>CFBundleName</key>
  14 + <string>$(PRODUCT_NAME)</string>
  15 + <key>CFBundlePackageType</key>
  16 + <string>APPL</string>
  17 + <key>CFBundleShortVersionString</key>
  18 + <string>1.0</string>
  19 + <key>CFBundleSignature</key>
  20 + <string>????</string>
  21 + <key>CFBundleVersion</key>
  22 + <string>1</string>
  23 + <key>LSRequiresIPhoneOS</key>
  24 + <true/>
  25 + <key>UILaunchStoryboardName</key>
  26 + <string>LaunchScreen</string>
  27 + <key>UIMainStoryboardFile</key>
  28 + <string>Main</string>
  29 + <key>UIRequiredDeviceCapabilities</key>
  30 + <array>
  31 + <string>armv7</string>
  32 + </array>
  33 + <key>UISupportedInterfaceOrientations</key>
  34 + <array>
  35 + <string>UIInterfaceOrientationPortrait</string>
  36 + <string>UIInterfaceOrientationLandscapeLeft</string>
  37 + <string>UIInterfaceOrientationLandscapeRight</string>
  38 + </array>
  39 + <key>UISupportedInterfaceOrientations~ipad</key>
  40 + <array>
  41 + <string>UIInterfaceOrientationPortrait</string>
  42 + <string>UIInterfaceOrientationPortraitUpsideDown</string>
  43 + <string>UIInterfaceOrientationLandscapeLeft</string>
  44 + <string>UIInterfaceOrientationLandscapeRight</string>
  45 + </array>
  46 + <key>NSAppTransportSecurity</key>
  47 + <dict>
  48 + <key>NSAllowsArbitraryLoads</key>
  49 + <true/>
  50 + </dict>
  51 +</dict>
  52 +</plist>
... ...
WSWebImageDemo/NSData+ImageContentType.h 0 → 100644
  1 +//
  2 +// NSData+ImageContentType.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/21.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface NSData (ImageContentType)
  12 +
  13 ++ (NSString *)ws_imageContentTypeWithData:(NSData *)data;
  14 +
  15 +@end
... ...
WSWebImageDemo/NSData+ImageContentType.m 0 → 100644
  1 +//
  2 +// NSData+ImageContentType.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/21.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "NSData+ImageContentType.h"
  10 +
  11 +@implementation NSData (ImageContentType)
  12 +
  13 ++ (NSString *)ws_imageContentTypeWithData:(NSData *)data
  14 +{
  15 + uint8_t c;
  16 + [data getBytes:&c length:1];
  17 + switch (c) {
  18 + case 0xFF:
  19 + return @"image/jpeg";
  20 + case 0x89:
  21 + return @"image/png";
  22 + case 0x47:
  23 + return @"image/gif";
  24 + case 0x49:
  25 + case 0x4D:
  26 + return @"image/tiff";
  27 + case 0x52:
  28 +
  29 + if ([data length] < 12) {
  30 + return nil;
  31 + }
  32 +
  33 + NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding];
  34 + if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) {
  35 + return @"image/webp";
  36 + }
  37 +
  38 + return nil;
  39 + }
  40 + return nil;
  41 +}
  42 +
  43 +@end
... ...
WSWebImageDemo/UIImage+MultiFormat.h 0 → 100644
  1 +//
  2 +// UIImage+MultiFormat.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/21.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface UIImage (MultiFormat)
  12 +
  13 ++ (UIImage *)ws_imageWithData:(NSData *)data;
  14 +
  15 +@end
... ...
WSWebImageDemo/UIImage+MultiFormat.m 0 → 100644
  1 +//
  2 +// UIImage+MultiFormat.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/21.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "UIImage+MultiFormat.h"
  10 +#import "NSData+ImageContentType.h"
  11 +
  12 +@implementation UIImage (MultiFormat)
  13 +
  14 ++ (UIImage *)ws_imageWithData:(NSData *)data
  15 +{
  16 + if (!data) {
  17 + return nil;
  18 + }
  19 + UIImage *image;
  20 + NSString *imageContentType = [NSData ws_imageContentTypeWithData:data];
  21 +
  22 + if ([imageContentType isEqualToString:@"image/gif"]) {
  23 + //TODO 处理GIF图片
  24 + }
  25 + else if ([imageContentType isEqualToString:@"image/webp"]) {
  26 + //TODO 处理WEBP图片
  27 + }
  28 + else {
  29 + image = [[UIImage alloc] initWithData:data];
  30 + }
  31 + return image;
  32 +}
  33 +
  34 +@end
... ...
WSWebImageDemo/UIImageView+WebCache.h 0 → 100644
  1 +//
  2 +// UIImageView+WebCache.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/26.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "CNLiveWebImageManager.h"
  11 +
  12 +@interface UIImageView (WebCache)
  13 +
  14 +- (void)ws_setImageWithUrl:(NSURL *)url;
  15 +
  16 +- (void)ws_setImageWithUrl:(NSURL *)url placeholderImage:(UIImage *)placeholder;
  17 +
  18 +@end
... ...
WSWebImageDemo/UIImageView+WebCache.m 0 → 100644
  1 +//
  2 +// UIImageView+WebCache.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/26.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "UIImageView+WebCache.h"
  10 +#import "CNLiveWebImageBlock.h"
  11 +
  12 +@implementation UIImageView (WebCache)
  13 +
  14 +- (void)ws_setImageWithUrl:(NSURL *)url
  15 +{
  16 + [self ws_setImageWithUrl:url placeholderImage:nil options:0 progress:nil completed:nil];
  17 +}
  18 +
  19 +- (void)ws_setImageWithUrl:(NSURL *)url placeholderImage:(UIImage *)placeholder
  20 +{
  21 + [self ws_setImageWithUrl:url placeholderImage:placeholder options:0 progress:nil completed:nil];
  22 +}
  23 +
  24 +- (void)ws_setImageWithUrl:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(CNLiveWebImageOptions)options progress:(CNLiveDownloadProgressBlock)progress completed:(CNLiveDownloadCompletedBlock)completed
  25 +{
  26 + if (placeholder) {
  27 + self.image = placeholder;
  28 + }
  29 +
  30 + if (url) {
  31 + __weak __typeof(self) weakSelf = self;
  32 + [[CNLiveWebImageManager sharedManager] downloadWebImageWithURL:url
  33 + options:options
  34 + progress:progress
  35 + completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
  36 + if (image && !error && finished) {
  37 + weakSelf.image = image;
  38 + }
  39 + }];
  40 + }
  41 + else {
  42 + dispatch_async(dispatch_get_main_queue(), ^{
  43 + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
  44 + if (completed) {
  45 + completed(nil, nil, error, NO);
  46 + }
  47 + });
  48 + }
  49 +
  50 +}
  51 +
  52 +@end
... ...
WSWebImageDemo/ViewController.h 0 → 100644
  1 +//
  2 +// ViewController.h
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface ViewController : UIViewController
  12 +
  13 +
  14 +@end
  15 +
... ...
WSWebImageDemo/ViewController.m 0 → 100644
  1 +//
  2 +// ViewController.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import "ViewController.h"
  10 +#import "CNLiveWebImageManager.h"
  11 +#import "CNLiveImageCache.h"
  12 +#import "UIImageView+WebCache.h"
  13 +
  14 +@interface ViewController ()
  15 +
  16 +@property (nonatomic, strong) UIImageView *imageView;
  17 +
  18 +@end
  19 +//static NSString *str = @"http://img.firefoxchina.cn/2016/07/4/201607261050080.jpg";
  20 +static NSString *str = @"http://desk.fd.zol-img.com.cn/t_s2560x1600c5/g5/M00/0D/0C/ChMkJ1eV8KuIKvxAADO4tztrTKcAAT0ZwCLaesAM7jP146.jpg";
  21 +//static NSString *str = @"http://pic104.nipic.com/file/20160720/21897230_115704969000_2.jpg";
  22 +
  23 +@implementation ViewController
  24 +
  25 +- (void)viewDidLoad {
  26 + [super viewDidLoad];
  27 + // Do any additional setup after loading the view, typically from a nib.
  28 +
  29 +// long long diskCacheSize = [[CNLiveImageCache sharedImageCache] diskCacheSize];
  30 +// NSLog(@"%lld",diskCacheSize);
  31 +//
  32 +// [self.view addSubview:self.imageView];
  33 +// [[CNLiveWebImageDownloadManager sharedManager] downloadWebImageWithURL:[NSURL URLWithString:str]
  34 +// options:CNLiveWebImageProgressiveDownload
  35 +// progress:^(NSInteger receivedSize, NSInteger expectedSize) {
  36 +// NSLog(@"receivedSize = %ld, expectedSize = %ld",(long)receivedSize, (long)expectedSize);
  37 +// }
  38 +// completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
  39 +// dispatch_async(dispatch_get_main_queue(), ^{
  40 +// self.imageView.image = image;
  41 +// });
  42 +// }];
  43 +
  44 +// [[CNLiveImageCache sharedImageCache] removeCacheForKey:@"http://img.firefoxchina.cn/2016/07/4/201607261050080.jpg" done:^{
  45 +// NSLog(@"Do something");
  46 +// }];
  47 +
  48 + UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
  49 + imageView.backgroundColor = [UIColor cyanColor];
  50 + [self.view addSubview:imageView];
  51 +
  52 +// [imageView ws_setImageWithUrl:[NSURL URLWithString:str]];
  53 + [imageView ws_setImageWithUrl:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"text.jpg"]];
  54 +}
  55 +
  56 +- (void)didReceiveMemoryWarning {
  57 + [super didReceiveMemoryWarning];
  58 + // Dispose of any resources that can be recreated.
  59 +}
  60 +
  61 +-(UIImageView *)imageView{
  62 + if (!_imageView) {
  63 + _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(40,40,300,200)];
  64 + _imageView.backgroundColor = [UIColor redColor];
  65 + _imageView.contentMode = UIViewContentModeScaleToFill;
  66 + }
  67 + return _imageView;
  68 +}
  69 +
  70 +@end
... ...
WSWebImageDemo/main.m 0 → 100644
  1 +//
  2 +// main.m
  3 +// WSWebImageDemo
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "AppDelegate.h"
  11 +
  12 +int main(int argc, char * argv[]) {
  13 + @autoreleasepool {
  14 + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
  15 + }
  16 +}
... ...
WSWebImageDemo/text.jpg 0 → 100644

41.4 KB

WSWebImageDemoTests/Info.plist 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>CFBundleDevelopmentRegion</key>
  6 + <string>en</string>
  7 + <key>CFBundleExecutable</key>
  8 + <string>$(EXECUTABLE_NAME)</string>
  9 + <key>CFBundleIdentifier</key>
  10 + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
  11 + <key>CFBundleInfoDictionaryVersion</key>
  12 + <string>6.0</string>
  13 + <key>CFBundleName</key>
  14 + <string>$(PRODUCT_NAME)</string>
  15 + <key>CFBundlePackageType</key>
  16 + <string>BNDL</string>
  17 + <key>CFBundleShortVersionString</key>
  18 + <string>1.0</string>
  19 + <key>CFBundleSignature</key>
  20 + <string>????</string>
  21 + <key>CFBundleVersion</key>
  22 + <string>1</string>
  23 +</dict>
  24 +</plist>
... ...
WSWebImageDemoTests/WSWebImageDemoTests.m 0 → 100644
  1 +//
  2 +// WSWebImageDemoTests.m
  3 +// WSWebImageDemoTests
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <XCTest/XCTest.h>
  10 +
  11 +@interface WSWebImageDemoTests : XCTestCase
  12 +
  13 +@end
  14 +
  15 +@implementation WSWebImageDemoTests
  16 +
  17 +- (void)setUp {
  18 + [super setUp];
  19 + // Put setup code here. This method is called before the invocation of each test method in the class.
  20 +}
  21 +
  22 +- (void)tearDown {
  23 + // Put teardown code here. This method is called after the invocation of each test method in the class.
  24 + [super tearDown];
  25 +}
  26 +
  27 +- (void)testExample {
  28 + // This is an example of a functional test case.
  29 + // Use XCTAssert and related functions to verify your tests produce the correct results.
  30 +}
  31 +
  32 +- (void)testPerformanceExample {
  33 + // This is an example of a performance test case.
  34 + [self measureBlock:^{
  35 + // Put the code you want to measure the time of here.
  36 + }];
  37 +}
  38 +
  39 +@end
... ...
WSWebImageDemoUITests/Info.plist 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>CFBundleDevelopmentRegion</key>
  6 + <string>en</string>
  7 + <key>CFBundleExecutable</key>
  8 + <string>$(EXECUTABLE_NAME)</string>
  9 + <key>CFBundleIdentifier</key>
  10 + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
  11 + <key>CFBundleInfoDictionaryVersion</key>
  12 + <string>6.0</string>
  13 + <key>CFBundleName</key>
  14 + <string>$(PRODUCT_NAME)</string>
  15 + <key>CFBundlePackageType</key>
  16 + <string>BNDL</string>
  17 + <key>CFBundleShortVersionString</key>
  18 + <string>1.0</string>
  19 + <key>CFBundleSignature</key>
  20 + <string>????</string>
  21 + <key>CFBundleVersion</key>
  22 + <string>1</string>
  23 +</dict>
  24 +</plist>
... ...
WSWebImageDemoUITests/WSWebImageDemoUITests.m 0 → 100644
  1 +//
  2 +// WSWebImageDemoUITests.m
  3 +// WSWebImageDemoUITests
  4 +//
  5 +// Created by 王帅 on 16/7/14.
  6 +// Copyright © 2016年 王帅. All rights reserved.
  7 +//
  8 +
  9 +#import <XCTest/XCTest.h>
  10 +
  11 +@interface WSWebImageDemoUITests : XCTestCase
  12 +
  13 +@end
  14 +
  15 +@implementation WSWebImageDemoUITests
  16 +
  17 +- (void)setUp {
  18 + [super setUp];
  19 +
  20 + // Put setup code here. This method is called before the invocation of each test method in the class.
  21 +
  22 + // In UI tests it is usually best to stop immediately when a failure occurs.
  23 + self.continueAfterFailure = NO;
  24 + // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
  25 + [[[XCUIApplication alloc] init] launch];
  26 +
  27 + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
  28 +}
  29 +
  30 +- (void)tearDown {
  31 + // Put teardown code here. This method is called after the invocation of each test method in the class.
  32 + [super tearDown];
  33 +}
  34 +
  35 +- (void)testExample {
  36 + // Use recording to get started writing UI tests.
  37 + // Use XCTAssert and related functions to verify your tests produce the correct results.
  38 +}
  39 +
  40 +@end
... ...