├── CleanCache.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── sunzhaokai.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── sunzhaokai.xcuserdatad │ └── xcschemes │ ├── CleanCache.xcscheme │ └── xcschememanagement.plist ├── CleanCache ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── CleanCacheTests ├── CleanCacheTests.m └── Info.plist ├── CleanCacheUITests ├── CleanCacheUITests.m └── Info.plist ├── README.md ├── SZKCleanCache.h └── SZKCleanCache.m /CleanCache.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8AFF6C591CE2C7A500026224 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AFF6C581CE2C7A500026224 /* main.m */; }; 11 | 8AFF6C5C1CE2C7A500026224 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AFF6C5B1CE2C7A500026224 /* AppDelegate.m */; }; 12 | 8AFF6C5F1CE2C7A500026224 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AFF6C5E1CE2C7A500026224 /* ViewController.m */; }; 13 | 8AFF6C621CE2C7A500026224 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8AFF6C601CE2C7A500026224 /* Main.storyboard */; }; 14 | 8AFF6C641CE2C7A500026224 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8AFF6C631CE2C7A500026224 /* Assets.xcassets */; }; 15 | 8AFF6C671CE2C7A500026224 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8AFF6C651CE2C7A500026224 /* LaunchScreen.storyboard */; }; 16 | 8AFF6C721CE2C7A500026224 /* CleanCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AFF6C711CE2C7A500026224 /* CleanCacheTests.m */; }; 17 | 8AFF6C7D1CE2C7A500026224 /* CleanCacheUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AFF6C7C1CE2C7A500026224 /* CleanCacheUITests.m */; }; 18 | 8AFF6C8D1CE2CB3900026224 /* SZKCleanCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AFF6C8C1CE2CB3900026224 /* SZKCleanCache.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 8AFF6C6E1CE2C7A500026224 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 8AFF6C4C1CE2C7A500026224 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 8AFF6C531CE2C7A500026224; 27 | remoteInfo = CleanCache; 28 | }; 29 | 8AFF6C791CE2C7A500026224 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 8AFF6C4C1CE2C7A500026224 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 8AFF6C531CE2C7A500026224; 34 | remoteInfo = CleanCache; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 8AFF6C541CE2C7A500026224 /* CleanCache.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CleanCache.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 8AFF6C581CE2C7A500026224 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | 8AFF6C5A1CE2C7A500026224 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | 8AFF6C5B1CE2C7A500026224 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | 8AFF6C5D1CE2C7A500026224 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 44 | 8AFF6C5E1CE2C7A500026224 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 45 | 8AFF6C611CE2C7A500026224 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 8AFF6C631CE2C7A500026224 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 8AFF6C661CE2C7A500026224 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 8AFF6C681CE2C7A500026224 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 8AFF6C6D1CE2C7A500026224 /* CleanCacheTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CleanCacheTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 8AFF6C711CE2C7A500026224 /* CleanCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CleanCacheTests.m; sourceTree = ""; }; 51 | 8AFF6C731CE2C7A500026224 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 8AFF6C781CE2C7A500026224 /* CleanCacheUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CleanCacheUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 8AFF6C7C1CE2C7A500026224 /* CleanCacheUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CleanCacheUITests.m; sourceTree = ""; }; 54 | 8AFF6C7E1CE2C7A500026224 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 8AFF6C8B1CE2CB3900026224 /* SZKCleanCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SZKCleanCache.h; sourceTree = ""; }; 56 | 8AFF6C8C1CE2CB3900026224 /* SZKCleanCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SZKCleanCache.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 8AFF6C511CE2C7A500026224 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 8AFF6C6A1CE2C7A500026224 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 8AFF6C751CE2C7A500026224 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 8AFF6C4B1CE2C7A500026224 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 8AFF6C8A1CE2C7C700026224 /* SZKCleanCache */, 88 | 8AFF6C561CE2C7A500026224 /* CleanCache */, 89 | 8AFF6C701CE2C7A500026224 /* CleanCacheTests */, 90 | 8AFF6C7B1CE2C7A500026224 /* CleanCacheUITests */, 91 | 8AFF6C551CE2C7A500026224 /* Products */, 92 | ); 93 | sourceTree = ""; 94 | }; 95 | 8AFF6C551CE2C7A500026224 /* Products */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 8AFF6C541CE2C7A500026224 /* CleanCache.app */, 99 | 8AFF6C6D1CE2C7A500026224 /* CleanCacheTests.xctest */, 100 | 8AFF6C781CE2C7A500026224 /* CleanCacheUITests.xctest */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 8AFF6C561CE2C7A500026224 /* CleanCache */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 8AFF6C5A1CE2C7A500026224 /* AppDelegate.h */, 109 | 8AFF6C5B1CE2C7A500026224 /* AppDelegate.m */, 110 | 8AFF6C5D1CE2C7A500026224 /* ViewController.h */, 111 | 8AFF6C5E1CE2C7A500026224 /* ViewController.m */, 112 | 8AFF6C601CE2C7A500026224 /* Main.storyboard */, 113 | 8AFF6C631CE2C7A500026224 /* Assets.xcassets */, 114 | 8AFF6C651CE2C7A500026224 /* LaunchScreen.storyboard */, 115 | 8AFF6C681CE2C7A500026224 /* Info.plist */, 116 | 8AFF6C571CE2C7A500026224 /* Supporting Files */, 117 | ); 118 | path = CleanCache; 119 | sourceTree = ""; 120 | }; 121 | 8AFF6C571CE2C7A500026224 /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 8AFF6C581CE2C7A500026224 /* main.m */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | 8AFF6C701CE2C7A500026224 /* CleanCacheTests */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 8AFF6C711CE2C7A500026224 /* CleanCacheTests.m */, 133 | 8AFF6C731CE2C7A500026224 /* Info.plist */, 134 | ); 135 | path = CleanCacheTests; 136 | sourceTree = ""; 137 | }; 138 | 8AFF6C7B1CE2C7A500026224 /* CleanCacheUITests */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 8AFF6C7C1CE2C7A500026224 /* CleanCacheUITests.m */, 142 | 8AFF6C7E1CE2C7A500026224 /* Info.plist */, 143 | ); 144 | path = CleanCacheUITests; 145 | sourceTree = ""; 146 | }; 147 | 8AFF6C8A1CE2C7C700026224 /* SZKCleanCache */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 8AFF6C8B1CE2CB3900026224 /* SZKCleanCache.h */, 151 | 8AFF6C8C1CE2CB3900026224 /* SZKCleanCache.m */, 152 | ); 153 | name = SZKCleanCache; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXNativeTarget section */ 159 | 8AFF6C531CE2C7A500026224 /* CleanCache */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = 8AFF6C811CE2C7A500026224 /* Build configuration list for PBXNativeTarget "CleanCache" */; 162 | buildPhases = ( 163 | 8AFF6C501CE2C7A500026224 /* Sources */, 164 | 8AFF6C511CE2C7A500026224 /* Frameworks */, 165 | 8AFF6C521CE2C7A500026224 /* Resources */, 166 | ); 167 | buildRules = ( 168 | ); 169 | dependencies = ( 170 | ); 171 | name = CleanCache; 172 | productName = CleanCache; 173 | productReference = 8AFF6C541CE2C7A500026224 /* CleanCache.app */; 174 | productType = "com.apple.product-type.application"; 175 | }; 176 | 8AFF6C6C1CE2C7A500026224 /* CleanCacheTests */ = { 177 | isa = PBXNativeTarget; 178 | buildConfigurationList = 8AFF6C841CE2C7A500026224 /* Build configuration list for PBXNativeTarget "CleanCacheTests" */; 179 | buildPhases = ( 180 | 8AFF6C691CE2C7A500026224 /* Sources */, 181 | 8AFF6C6A1CE2C7A500026224 /* Frameworks */, 182 | 8AFF6C6B1CE2C7A500026224 /* Resources */, 183 | ); 184 | buildRules = ( 185 | ); 186 | dependencies = ( 187 | 8AFF6C6F1CE2C7A500026224 /* PBXTargetDependency */, 188 | ); 189 | name = CleanCacheTests; 190 | productName = CleanCacheTests; 191 | productReference = 8AFF6C6D1CE2C7A500026224 /* CleanCacheTests.xctest */; 192 | productType = "com.apple.product-type.bundle.unit-test"; 193 | }; 194 | 8AFF6C771CE2C7A500026224 /* CleanCacheUITests */ = { 195 | isa = PBXNativeTarget; 196 | buildConfigurationList = 8AFF6C871CE2C7A500026224 /* Build configuration list for PBXNativeTarget "CleanCacheUITests" */; 197 | buildPhases = ( 198 | 8AFF6C741CE2C7A500026224 /* Sources */, 199 | 8AFF6C751CE2C7A500026224 /* Frameworks */, 200 | 8AFF6C761CE2C7A500026224 /* Resources */, 201 | ); 202 | buildRules = ( 203 | ); 204 | dependencies = ( 205 | 8AFF6C7A1CE2C7A500026224 /* PBXTargetDependency */, 206 | ); 207 | name = CleanCacheUITests; 208 | productName = CleanCacheUITests; 209 | productReference = 8AFF6C781CE2C7A500026224 /* CleanCacheUITests.xctest */; 210 | productType = "com.apple.product-type.bundle.ui-testing"; 211 | }; 212 | /* End PBXNativeTarget section */ 213 | 214 | /* Begin PBXProject section */ 215 | 8AFF6C4C1CE2C7A500026224 /* Project object */ = { 216 | isa = PBXProject; 217 | attributes = { 218 | LastUpgradeCheck = 0730; 219 | ORGANIZATIONNAME = "孙赵凯"; 220 | TargetAttributes = { 221 | 8AFF6C531CE2C7A500026224 = { 222 | CreatedOnToolsVersion = 7.3; 223 | }; 224 | 8AFF6C6C1CE2C7A500026224 = { 225 | CreatedOnToolsVersion = 7.3; 226 | TestTargetID = 8AFF6C531CE2C7A500026224; 227 | }; 228 | 8AFF6C771CE2C7A500026224 = { 229 | CreatedOnToolsVersion = 7.3; 230 | TestTargetID = 8AFF6C531CE2C7A500026224; 231 | }; 232 | }; 233 | }; 234 | buildConfigurationList = 8AFF6C4F1CE2C7A500026224 /* Build configuration list for PBXProject "CleanCache" */; 235 | compatibilityVersion = "Xcode 3.2"; 236 | developmentRegion = English; 237 | hasScannedForEncodings = 0; 238 | knownRegions = ( 239 | en, 240 | Base, 241 | ); 242 | mainGroup = 8AFF6C4B1CE2C7A500026224; 243 | productRefGroup = 8AFF6C551CE2C7A500026224 /* Products */; 244 | projectDirPath = ""; 245 | projectRoot = ""; 246 | targets = ( 247 | 8AFF6C531CE2C7A500026224 /* CleanCache */, 248 | 8AFF6C6C1CE2C7A500026224 /* CleanCacheTests */, 249 | 8AFF6C771CE2C7A500026224 /* CleanCacheUITests */, 250 | ); 251 | }; 252 | /* End PBXProject section */ 253 | 254 | /* Begin PBXResourcesBuildPhase section */ 255 | 8AFF6C521CE2C7A500026224 /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | 8AFF6C671CE2C7A500026224 /* LaunchScreen.storyboard in Resources */, 260 | 8AFF6C641CE2C7A500026224 /* Assets.xcassets in Resources */, 261 | 8AFF6C621CE2C7A500026224 /* Main.storyboard in Resources */, 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | }; 265 | 8AFF6C6B1CE2C7A500026224 /* Resources */ = { 266 | isa = PBXResourcesBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | 8AFF6C761CE2C7A500026224 /* Resources */ = { 273 | isa = PBXResourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | /* End PBXResourcesBuildPhase section */ 280 | 281 | /* Begin PBXSourcesBuildPhase section */ 282 | 8AFF6C501CE2C7A500026224 /* Sources */ = { 283 | isa = PBXSourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | 8AFF6C5F1CE2C7A500026224 /* ViewController.m in Sources */, 287 | 8AFF6C8D1CE2CB3900026224 /* SZKCleanCache.m in Sources */, 288 | 8AFF6C5C1CE2C7A500026224 /* AppDelegate.m in Sources */, 289 | 8AFF6C591CE2C7A500026224 /* main.m in Sources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | 8AFF6C691CE2C7A500026224 /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | 8AFF6C721CE2C7A500026224 /* CleanCacheTests.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | 8AFF6C741CE2C7A500026224 /* Sources */ = { 302 | isa = PBXSourcesBuildPhase; 303 | buildActionMask = 2147483647; 304 | files = ( 305 | 8AFF6C7D1CE2C7A500026224 /* CleanCacheUITests.m in Sources */, 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | /* End PBXSourcesBuildPhase section */ 310 | 311 | /* Begin PBXTargetDependency section */ 312 | 8AFF6C6F1CE2C7A500026224 /* PBXTargetDependency */ = { 313 | isa = PBXTargetDependency; 314 | target = 8AFF6C531CE2C7A500026224 /* CleanCache */; 315 | targetProxy = 8AFF6C6E1CE2C7A500026224 /* PBXContainerItemProxy */; 316 | }; 317 | 8AFF6C7A1CE2C7A500026224 /* PBXTargetDependency */ = { 318 | isa = PBXTargetDependency; 319 | target = 8AFF6C531CE2C7A500026224 /* CleanCache */; 320 | targetProxy = 8AFF6C791CE2C7A500026224 /* PBXContainerItemProxy */; 321 | }; 322 | /* End PBXTargetDependency section */ 323 | 324 | /* Begin PBXVariantGroup section */ 325 | 8AFF6C601CE2C7A500026224 /* Main.storyboard */ = { 326 | isa = PBXVariantGroup; 327 | children = ( 328 | 8AFF6C611CE2C7A500026224 /* Base */, 329 | ); 330 | name = Main.storyboard; 331 | sourceTree = ""; 332 | }; 333 | 8AFF6C651CE2C7A500026224 /* LaunchScreen.storyboard */ = { 334 | isa = PBXVariantGroup; 335 | children = ( 336 | 8AFF6C661CE2C7A500026224 /* Base */, 337 | ); 338 | name = LaunchScreen.storyboard; 339 | sourceTree = ""; 340 | }; 341 | /* End PBXVariantGroup section */ 342 | 343 | /* Begin XCBuildConfiguration section */ 344 | 8AFF6C7F1CE2C7A500026224 /* Debug */ = { 345 | isa = XCBuildConfiguration; 346 | buildSettings = { 347 | ALWAYS_SEARCH_USER_PATHS = NO; 348 | CLANG_ANALYZER_NONNULL = YES; 349 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 350 | CLANG_CXX_LIBRARY = "libc++"; 351 | CLANG_ENABLE_MODULES = YES; 352 | CLANG_ENABLE_OBJC_ARC = YES; 353 | CLANG_WARN_BOOL_CONVERSION = YES; 354 | CLANG_WARN_CONSTANT_CONVERSION = YES; 355 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 356 | CLANG_WARN_EMPTY_BODY = YES; 357 | CLANG_WARN_ENUM_CONVERSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 360 | CLANG_WARN_UNREACHABLE_CODE = YES; 361 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 362 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 363 | COPY_PHASE_STRIP = NO; 364 | DEBUG_INFORMATION_FORMAT = dwarf; 365 | ENABLE_STRICT_OBJC_MSGSEND = YES; 366 | ENABLE_TESTABILITY = YES; 367 | GCC_C_LANGUAGE_STANDARD = gnu99; 368 | GCC_DYNAMIC_NO_PIC = NO; 369 | GCC_NO_COMMON_BLOCKS = YES; 370 | GCC_OPTIMIZATION_LEVEL = 0; 371 | GCC_PREPROCESSOR_DEFINITIONS = ( 372 | "DEBUG=1", 373 | "$(inherited)", 374 | ); 375 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 376 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 377 | GCC_WARN_UNDECLARED_SELECTOR = YES; 378 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 379 | GCC_WARN_UNUSED_FUNCTION = YES; 380 | GCC_WARN_UNUSED_VARIABLE = YES; 381 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 382 | MTL_ENABLE_DEBUG_INFO = YES; 383 | ONLY_ACTIVE_ARCH = YES; 384 | SDKROOT = iphoneos; 385 | TARGETED_DEVICE_FAMILY = "1,2"; 386 | }; 387 | name = Debug; 388 | }; 389 | 8AFF6C801CE2C7A500026224 /* Release */ = { 390 | isa = XCBuildConfiguration; 391 | buildSettings = { 392 | ALWAYS_SEARCH_USER_PATHS = NO; 393 | CLANG_ANALYZER_NONNULL = YES; 394 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 395 | CLANG_CXX_LIBRARY = "libc++"; 396 | CLANG_ENABLE_MODULES = YES; 397 | CLANG_ENABLE_OBJC_ARC = YES; 398 | CLANG_WARN_BOOL_CONVERSION = YES; 399 | CLANG_WARN_CONSTANT_CONVERSION = YES; 400 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 401 | CLANG_WARN_EMPTY_BODY = YES; 402 | CLANG_WARN_ENUM_CONVERSION = YES; 403 | CLANG_WARN_INT_CONVERSION = YES; 404 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 405 | CLANG_WARN_UNREACHABLE_CODE = YES; 406 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 407 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 408 | COPY_PHASE_STRIP = NO; 409 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 410 | ENABLE_NS_ASSERTIONS = NO; 411 | ENABLE_STRICT_OBJC_MSGSEND = YES; 412 | GCC_C_LANGUAGE_STANDARD = gnu99; 413 | GCC_NO_COMMON_BLOCKS = YES; 414 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 415 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 416 | GCC_WARN_UNDECLARED_SELECTOR = YES; 417 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 418 | GCC_WARN_UNUSED_FUNCTION = YES; 419 | GCC_WARN_UNUSED_VARIABLE = YES; 420 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 421 | MTL_ENABLE_DEBUG_INFO = NO; 422 | SDKROOT = iphoneos; 423 | TARGETED_DEVICE_FAMILY = "1,2"; 424 | VALIDATE_PRODUCT = YES; 425 | }; 426 | name = Release; 427 | }; 428 | 8AFF6C821CE2C7A500026224 /* Debug */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | INFOPLIST_FILE = CleanCache/Info.plist; 433 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 434 | PRODUCT_BUNDLE_IDENTIFIER = "---.CleanCache"; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | }; 437 | name = Debug; 438 | }; 439 | 8AFF6C831CE2C7A500026224 /* Release */ = { 440 | isa = XCBuildConfiguration; 441 | buildSettings = { 442 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 443 | INFOPLIST_FILE = CleanCache/Info.plist; 444 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 445 | PRODUCT_BUNDLE_IDENTIFIER = "---.CleanCache"; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | }; 448 | name = Release; 449 | }; 450 | 8AFF6C851CE2C7A500026224 /* Debug */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | BUNDLE_LOADER = "$(TEST_HOST)"; 454 | INFOPLIST_FILE = CleanCacheTests/Info.plist; 455 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 456 | PRODUCT_BUNDLE_IDENTIFIER = "---.CleanCacheTests"; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CleanCache.app/CleanCache"; 459 | }; 460 | name = Debug; 461 | }; 462 | 8AFF6C861CE2C7A500026224 /* Release */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | BUNDLE_LOADER = "$(TEST_HOST)"; 466 | INFOPLIST_FILE = CleanCacheTests/Info.plist; 467 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 468 | PRODUCT_BUNDLE_IDENTIFIER = "---.CleanCacheTests"; 469 | PRODUCT_NAME = "$(TARGET_NAME)"; 470 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CleanCache.app/CleanCache"; 471 | }; 472 | name = Release; 473 | }; 474 | 8AFF6C881CE2C7A500026224 /* Debug */ = { 475 | isa = XCBuildConfiguration; 476 | buildSettings = { 477 | INFOPLIST_FILE = CleanCacheUITests/Info.plist; 478 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 479 | PRODUCT_BUNDLE_IDENTIFIER = "---.CleanCacheUITests"; 480 | PRODUCT_NAME = "$(TARGET_NAME)"; 481 | TEST_TARGET_NAME = CleanCache; 482 | }; 483 | name = Debug; 484 | }; 485 | 8AFF6C891CE2C7A500026224 /* Release */ = { 486 | isa = XCBuildConfiguration; 487 | buildSettings = { 488 | INFOPLIST_FILE = CleanCacheUITests/Info.plist; 489 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 490 | PRODUCT_BUNDLE_IDENTIFIER = "---.CleanCacheUITests"; 491 | PRODUCT_NAME = "$(TARGET_NAME)"; 492 | TEST_TARGET_NAME = CleanCache; 493 | }; 494 | name = Release; 495 | }; 496 | /* End XCBuildConfiguration section */ 497 | 498 | /* Begin XCConfigurationList section */ 499 | 8AFF6C4F1CE2C7A500026224 /* Build configuration list for PBXProject "CleanCache" */ = { 500 | isa = XCConfigurationList; 501 | buildConfigurations = ( 502 | 8AFF6C7F1CE2C7A500026224 /* Debug */, 503 | 8AFF6C801CE2C7A500026224 /* Release */, 504 | ); 505 | defaultConfigurationIsVisible = 0; 506 | defaultConfigurationName = Release; 507 | }; 508 | 8AFF6C811CE2C7A500026224 /* Build configuration list for PBXNativeTarget "CleanCache" */ = { 509 | isa = XCConfigurationList; 510 | buildConfigurations = ( 511 | 8AFF6C821CE2C7A500026224 /* Debug */, 512 | 8AFF6C831CE2C7A500026224 /* Release */, 513 | ); 514 | defaultConfigurationIsVisible = 0; 515 | }; 516 | 8AFF6C841CE2C7A500026224 /* Build configuration list for PBXNativeTarget "CleanCacheTests" */ = { 517 | isa = XCConfigurationList; 518 | buildConfigurations = ( 519 | 8AFF6C851CE2C7A500026224 /* Debug */, 520 | 8AFF6C861CE2C7A500026224 /* Release */, 521 | ); 522 | defaultConfigurationIsVisible = 0; 523 | }; 524 | 8AFF6C871CE2C7A500026224 /* Build configuration list for PBXNativeTarget "CleanCacheUITests" */ = { 525 | isa = XCConfigurationList; 526 | buildConfigurations = ( 527 | 8AFF6C881CE2C7A500026224 /* Debug */, 528 | 8AFF6C891CE2C7A500026224 /* Release */, 529 | ); 530 | defaultConfigurationIsVisible = 0; 531 | }; 532 | /* End XCConfigurationList section */ 533 | }; 534 | rootObject = 8AFF6C4C1CE2C7A500026224 /* Project object */; 535 | } 536 | -------------------------------------------------------------------------------- /CleanCache.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CleanCache.xcodeproj/project.xcworkspace/xcuserdata/sunzhaokai.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/18811314750/SZKCleanCache/f610fa200ab7a03173f7bbb6aa25e3f054cdd1fb/CleanCache.xcodeproj/project.xcworkspace/xcuserdata/sunzhaokai.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CleanCache.xcodeproj/xcuserdata/sunzhaokai.xcuserdatad/xcschemes/CleanCache.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /CleanCache.xcodeproj/xcuserdata/sunzhaokai.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CleanCache.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 8AFF6C531CE2C7A500026224 16 | 17 | primary 18 | 19 | 20 | 8AFF6C6C1CE2C7A500026224 21 | 22 | primary 23 | 24 | 25 | 8AFF6C771CE2C7A500026224 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /CleanCache/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CleanCache 4 | // 5 | // Created by sunzhaokai on 16/5/11. 6 | // Copyright © 2016年 孙赵凯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CleanCache/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CleanCache 4 | // 5 | // Created by sunzhaokai on 16/5/11. 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 46 | -------------------------------------------------------------------------------- /CleanCache/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 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 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /CleanCache/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /CleanCache/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CleanCache/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /CleanCache/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CleanCache 4 | // 5 | // Created by sunzhaokai on 16/5/11. 6 | // Copyright © 2016年 孙赵凯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CleanCache/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CleanCache 4 | // 5 | // Created by sunzhaokai on 16/5/11. 6 | // Copyright © 2016年 孙赵凯. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | #import "SZKCleanCache.h" 12 | 13 | @interface ViewController () 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | //输出缓存大小 m 23 | NSLog(@"%.2fm",[SZKCleanCache folderSizeAtPath]); 24 | 25 | //清楚缓存 26 | [SZKCleanCache cleanCache:^{ 27 | NSLog(@"清除成功"); 28 | }]; 29 | 30 | 31 | 32 | 33 | } 34 | 35 | - (void)didReceiveMemoryWarning { 36 | [super didReceiveMemoryWarning]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CleanCache/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CleanCache 4 | // 5 | // Created by sunzhaokai on 16/5/11. 6 | // Copyright © 2016年 孙赵凯. All rights reserved. 7 | // 8 | 9 | #import 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 | } 17 | -------------------------------------------------------------------------------- /CleanCacheTests/CleanCacheTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CleanCacheTests.m 3 | // CleanCacheTests 4 | // 5 | // Created by sunzhaokai on 16/5/11. 6 | // Copyright © 2016年 孙赵凯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CleanCacheTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CleanCacheTests 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 40 | -------------------------------------------------------------------------------- /CleanCacheTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /CleanCacheUITests/CleanCacheUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CleanCacheUITests.m 3 | // CleanCacheUITests 4 | // 5 | // Created by sunzhaokai on 16/5/11. 6 | // Copyright © 2016年 孙赵凯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CleanCacheUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CleanCacheUITests 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 41 | -------------------------------------------------------------------------------- /CleanCacheUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SZKCleanCache 2 | iOS开发-清理缓存,将计算缓存,清理缓存封装成类方法,并将清理结果利用block方法实现返回,一键调用,轻松实现 3 | 4 | SZKCleanCache 详细介绍:http://www.jianshu.com/p/5ebe4f21c486 5 | 6 | 封装的SZKCleanCache.h中 7 | 8 | ``` 9 | #import 10 | 11 | typedef void(^cleanCacheBlock)(); 12 | 13 | @interface SZKCleanCache : NSObject 14 | /** 15 | * 清理缓存 16 | */ 17 | +(void)cleanCache:(cleanCacheBlock)block; 18 | /** 19 | * 整个缓存目录的大小 20 | */ 21 | +(float)folderSizeAtPath; 22 | 23 | @end 24 | ``` 25 | 26 | SZKCleanCache.m中实现方法: 27 | 28 | ``` 29 | /** 30 | * 计算单个文件大小 31 | */ 32 | +(long long)fileSizeAtPath:(NSString *)filePath{ 33 | 34 | NSFileManager *manager = [NSFileManager defaultManager]; 35 | 36 | if ([manager fileExistsAtPath :filePath]){ 37 | 38 | return [[manager attributesOfItemAtPath :filePath error : nil ] fileSize]; 39 | } 40 | return 0 ; 41 | 42 | } 43 | ``` 44 | 45 | ``` 46 | /** 47 | * 计算整个目录大小 48 | */ 49 | +(float)folderSizeAtPath 50 | { 51 | NSString *folderPath=[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]; 52 | 53 | NSFileManager * manager=[NSFileManager defaultManager ]; 54 | if (![manager fileExistsAtPath :folderPath]) { 55 | return 0 ; 56 | } 57 | NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath :folderPath] objectEnumerator ]; 58 | NSString * fileName; 59 | long long folderSize = 0 ; 60 | while ((fileName = [childFilesEnumerator nextObject ]) != nil ){ 61 | NSString * fileAbsolutePath = [folderPath stringByAppendingPathComponent :fileName]; 62 | folderSize += [ self fileSizeAtPath :fileAbsolutePath]; 63 | } 64 | 65 | return folderSize/( 1024.0 * 1024.0 ); 66 | } 67 | 68 | ``` 69 | 70 | ``` 71 | /** 72 | * 清理缓存 73 | */ 74 | +(void)cleanCache:(cleanCacheBlock)block 75 | { 76 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 77 | //文件路径 78 | NSString *directoryPath=[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]; 79 | 80 | NSArray *subpaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil]; 81 | 82 | for (NSString *subPath in subpaths) { 83 | NSString *filePath = [directoryPath stringByAppendingPathComponent:subPath]; 84 | [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; 85 | } 86 | //返回主线程 87 | dispatch_async(dispatch_get_main_queue(), ^{ 88 | block(); 89 | }); 90 | }); 91 | 92 | } 93 | 94 | ``` 95 | 96 | SZKCleanCache 详细介绍:http://www.jianshu.com/p/5ebe4f21c486 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /SZKCleanCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // SZKCleanCache.h 3 | // CleanCache 4 | // 5 | // Created by sunzhaokai on 16/5/11. 6 | // Copyright © 2016年 孙赵凯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | typedef void(^cleanCacheBlock)(); 13 | 14 | 15 | @interface SZKCleanCache : NSObject 16 | 17 | /** 18 | * 清理缓存 19 | */ 20 | +(void)cleanCache:(cleanCacheBlock)block; 21 | 22 | /** 23 | * 整个缓存目录的大小 24 | */ 25 | +(float)folderSizeAtPath; 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /SZKCleanCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // SZKCleanCache.m 3 | // CleanCache 4 | // 5 | // Created by sunzhaokai on 16/5/11. 6 | // Copyright © 2016年 孙赵凯. All rights reserved. 7 | // 8 | 9 | #import "SZKCleanCache.h" 10 | 11 | @implementation SZKCleanCache 12 | 13 | /** 14 | * 清理缓存 15 | */ 16 | +(void)cleanCache:(cleanCacheBlock)block 17 | { 18 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 19 | //文件路径 20 | NSString *directoryPath=[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]; 21 | 22 | NSArray *subpaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil]; 23 | 24 | for (NSString *subPath in subpaths) { 25 | NSString *filePath = [directoryPath stringByAppendingPathComponent:subPath]; 26 | [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; 27 | } 28 | //返回主线程 29 | dispatch_async(dispatch_get_main_queue(), ^{ 30 | block(); 31 | }); 32 | }); 33 | 34 | } 35 | /** 36 | * 计算整个目录大小 37 | */ 38 | +(float)folderSizeAtPath 39 | { 40 | NSString *folderPath=[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]; 41 | 42 | NSFileManager * manager=[NSFileManager defaultManager ]; 43 | if (![manager fileExistsAtPath :folderPath]) { 44 | return 0 ; 45 | } 46 | NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath :folderPath] objectEnumerator ]; 47 | NSString * fileName; 48 | long long folderSize = 0 ; 49 | while ((fileName = [childFilesEnumerator nextObject ]) != nil ){ 50 | NSString * fileAbsolutePath = [folderPath stringByAppendingPathComponent :fileName]; 51 | folderSize += [ self fileSizeAtPath :fileAbsolutePath]; 52 | } 53 | 54 | return folderSize/( 1024.0 * 1024.0 ); 55 | } 56 | /** 57 | * 计算单个文件大小 58 | */ 59 | +(long long)fileSizeAtPath:(NSString *)filePath{ 60 | 61 | NSFileManager *manager = [NSFileManager defaultManager]; 62 | 63 | if ([manager fileExistsAtPath :filePath]){ 64 | 65 | return [[manager attributesOfItemAtPath :filePath error : nil ] fileSize]; 66 | } 67 | return 0 ; 68 | 69 | } 70 | 71 | 72 | 73 | 74 | 75 | @end 76 | --------------------------------------------------------------------------------