├── ClearCache-Swift.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── huchunyuan.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── huchunyuan.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── ClearCache-Swift.xcscheme │ └── xcschememanagement.plist ├── ClearCache-Swift ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift └── README.md /ClearCache-Swift.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 528C95C41C11207B00A81C7F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 528C95C31C11207B00A81C7F /* AppDelegate.swift */; }; 11 | 528C95C61C11207B00A81C7F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 528C95C51C11207B00A81C7F /* ViewController.swift */; }; 12 | 528C95C91C11207B00A81C7F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 528C95C71C11207B00A81C7F /* Main.storyboard */; }; 13 | 528C95CB1C11207B00A81C7F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 528C95CA1C11207B00A81C7F /* Assets.xcassets */; }; 14 | 528C95CE1C11207B00A81C7F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 528C95CC1C11207B00A81C7F /* LaunchScreen.storyboard */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 528C95C01C11207B00A81C7F /* ClearCache-Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ClearCache-Swift.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 528C95C31C11207B00A81C7F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 20 | 528C95C51C11207B00A81C7F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 21 | 528C95C81C11207B00A81C7F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 22 | 528C95CA1C11207B00A81C7F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 528C95CD1C11207B00A81C7F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 24 | 528C95CF1C11207B00A81C7F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 528C95BD1C11207B00A81C7F /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 528C95B71C11207B00A81C7F = { 39 | isa = PBXGroup; 40 | children = ( 41 | 528C95C21C11207B00A81C7F /* ClearCache-Swift */, 42 | 528C95C11C11207B00A81C7F /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 528C95C11C11207B00A81C7F /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 528C95C01C11207B00A81C7F /* ClearCache-Swift.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 528C95C21C11207B00A81C7F /* ClearCache-Swift */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 528C95C31C11207B00A81C7F /* AppDelegate.swift */, 58 | 528C95C51C11207B00A81C7F /* ViewController.swift */, 59 | 528C95C71C11207B00A81C7F /* Main.storyboard */, 60 | 528C95CA1C11207B00A81C7F /* Assets.xcassets */, 61 | 528C95CC1C11207B00A81C7F /* LaunchScreen.storyboard */, 62 | 528C95CF1C11207B00A81C7F /* Info.plist */, 63 | ); 64 | path = "ClearCache-Swift"; 65 | sourceTree = ""; 66 | }; 67 | /* End PBXGroup section */ 68 | 69 | /* Begin PBXNativeTarget section */ 70 | 528C95BF1C11207B00A81C7F /* ClearCache-Swift */ = { 71 | isa = PBXNativeTarget; 72 | buildConfigurationList = 528C95D21C11207B00A81C7F /* Build configuration list for PBXNativeTarget "ClearCache-Swift" */; 73 | buildPhases = ( 74 | 528C95BC1C11207B00A81C7F /* Sources */, 75 | 528C95BD1C11207B00A81C7F /* Frameworks */, 76 | 528C95BE1C11207B00A81C7F /* Resources */, 77 | ); 78 | buildRules = ( 79 | ); 80 | dependencies = ( 81 | ); 82 | name = "ClearCache-Swift"; 83 | productName = "ClearCache-Swift"; 84 | productReference = 528C95C01C11207B00A81C7F /* ClearCache-Swift.app */; 85 | productType = "com.apple.product-type.application"; 86 | }; 87 | /* End PBXNativeTarget section */ 88 | 89 | /* Begin PBXProject section */ 90 | 528C95B81C11207B00A81C7F /* Project object */ = { 91 | isa = PBXProject; 92 | attributes = { 93 | LastSwiftUpdateCheck = 0710; 94 | LastUpgradeCheck = 0710; 95 | ORGANIZATIONNAME = huchunyuan; 96 | TargetAttributes = { 97 | 528C95BF1C11207B00A81C7F = { 98 | CreatedOnToolsVersion = 7.1.1; 99 | }; 100 | }; 101 | }; 102 | buildConfigurationList = 528C95BB1C11207B00A81C7F /* Build configuration list for PBXProject "ClearCache-Swift" */; 103 | compatibilityVersion = "Xcode 3.2"; 104 | developmentRegion = English; 105 | hasScannedForEncodings = 0; 106 | knownRegions = ( 107 | en, 108 | Base, 109 | ); 110 | mainGroup = 528C95B71C11207B00A81C7F; 111 | productRefGroup = 528C95C11C11207B00A81C7F /* Products */; 112 | projectDirPath = ""; 113 | projectRoot = ""; 114 | targets = ( 115 | 528C95BF1C11207B00A81C7F /* ClearCache-Swift */, 116 | ); 117 | }; 118 | /* End PBXProject section */ 119 | 120 | /* Begin PBXResourcesBuildPhase section */ 121 | 528C95BE1C11207B00A81C7F /* Resources */ = { 122 | isa = PBXResourcesBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | 528C95CE1C11207B00A81C7F /* LaunchScreen.storyboard in Resources */, 126 | 528C95CB1C11207B00A81C7F /* Assets.xcassets in Resources */, 127 | 528C95C91C11207B00A81C7F /* Main.storyboard in Resources */, 128 | ); 129 | runOnlyForDeploymentPostprocessing = 0; 130 | }; 131 | /* End PBXResourcesBuildPhase section */ 132 | 133 | /* Begin PBXSourcesBuildPhase section */ 134 | 528C95BC1C11207B00A81C7F /* Sources */ = { 135 | isa = PBXSourcesBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | 528C95C61C11207B00A81C7F /* ViewController.swift in Sources */, 139 | 528C95C41C11207B00A81C7F /* AppDelegate.swift in Sources */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXSourcesBuildPhase section */ 144 | 145 | /* Begin PBXVariantGroup section */ 146 | 528C95C71C11207B00A81C7F /* Main.storyboard */ = { 147 | isa = PBXVariantGroup; 148 | children = ( 149 | 528C95C81C11207B00A81C7F /* Base */, 150 | ); 151 | name = Main.storyboard; 152 | sourceTree = ""; 153 | }; 154 | 528C95CC1C11207B00A81C7F /* LaunchScreen.storyboard */ = { 155 | isa = PBXVariantGroup; 156 | children = ( 157 | 528C95CD1C11207B00A81C7F /* Base */, 158 | ); 159 | name = LaunchScreen.storyboard; 160 | sourceTree = ""; 161 | }; 162 | /* End PBXVariantGroup section */ 163 | 164 | /* Begin XCBuildConfiguration section */ 165 | 528C95D01C11207B00A81C7F /* Debug */ = { 166 | isa = XCBuildConfiguration; 167 | buildSettings = { 168 | ALWAYS_SEARCH_USER_PATHS = NO; 169 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 170 | CLANG_CXX_LIBRARY = "libc++"; 171 | CLANG_ENABLE_MODULES = YES; 172 | CLANG_ENABLE_OBJC_ARC = YES; 173 | CLANG_WARN_BOOL_CONVERSION = YES; 174 | CLANG_WARN_CONSTANT_CONVERSION = YES; 175 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 176 | CLANG_WARN_EMPTY_BODY = YES; 177 | CLANG_WARN_ENUM_CONVERSION = YES; 178 | CLANG_WARN_INT_CONVERSION = YES; 179 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 180 | CLANG_WARN_UNREACHABLE_CODE = YES; 181 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 182 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 183 | COPY_PHASE_STRIP = NO; 184 | DEBUG_INFORMATION_FORMAT = dwarf; 185 | ENABLE_STRICT_OBJC_MSGSEND = YES; 186 | ENABLE_TESTABILITY = YES; 187 | GCC_C_LANGUAGE_STANDARD = gnu99; 188 | GCC_DYNAMIC_NO_PIC = NO; 189 | GCC_NO_COMMON_BLOCKS = YES; 190 | GCC_OPTIMIZATION_LEVEL = 0; 191 | GCC_PREPROCESSOR_DEFINITIONS = ( 192 | "DEBUG=1", 193 | "$(inherited)", 194 | ); 195 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 196 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 197 | GCC_WARN_UNDECLARED_SELECTOR = YES; 198 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 199 | GCC_WARN_UNUSED_FUNCTION = YES; 200 | GCC_WARN_UNUSED_VARIABLE = YES; 201 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 202 | MTL_ENABLE_DEBUG_INFO = YES; 203 | ONLY_ACTIVE_ARCH = YES; 204 | SDKROOT = iphoneos; 205 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 206 | }; 207 | name = Debug; 208 | }; 209 | 528C95D11C11207B00A81C7F /* Release */ = { 210 | isa = XCBuildConfiguration; 211 | buildSettings = { 212 | ALWAYS_SEARCH_USER_PATHS = NO; 213 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 214 | CLANG_CXX_LIBRARY = "libc++"; 215 | CLANG_ENABLE_MODULES = YES; 216 | CLANG_ENABLE_OBJC_ARC = YES; 217 | CLANG_WARN_BOOL_CONVERSION = YES; 218 | CLANG_WARN_CONSTANT_CONVERSION = YES; 219 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 220 | CLANG_WARN_EMPTY_BODY = YES; 221 | CLANG_WARN_ENUM_CONVERSION = YES; 222 | CLANG_WARN_INT_CONVERSION = YES; 223 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 224 | CLANG_WARN_UNREACHABLE_CODE = YES; 225 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 226 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 227 | COPY_PHASE_STRIP = NO; 228 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 229 | ENABLE_NS_ASSERTIONS = NO; 230 | ENABLE_STRICT_OBJC_MSGSEND = YES; 231 | GCC_C_LANGUAGE_STANDARD = gnu99; 232 | GCC_NO_COMMON_BLOCKS = YES; 233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 235 | GCC_WARN_UNDECLARED_SELECTOR = YES; 236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 237 | GCC_WARN_UNUSED_FUNCTION = YES; 238 | GCC_WARN_UNUSED_VARIABLE = YES; 239 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 240 | MTL_ENABLE_DEBUG_INFO = NO; 241 | SDKROOT = iphoneos; 242 | VALIDATE_PRODUCT = YES; 243 | }; 244 | name = Release; 245 | }; 246 | 528C95D31C11207B00A81C7F /* Debug */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 250 | INFOPLIST_FILE = "ClearCache-Swift/Info.plist"; 251 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 252 | PRODUCT_BUNDLE_IDENTIFIER = "huchunyuan.ClearCache-Swift"; 253 | PRODUCT_NAME = "$(TARGET_NAME)"; 254 | }; 255 | name = Debug; 256 | }; 257 | 528C95D41C11207B00A81C7F /* Release */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 261 | INFOPLIST_FILE = "ClearCache-Swift/Info.plist"; 262 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 263 | PRODUCT_BUNDLE_IDENTIFIER = "huchunyuan.ClearCache-Swift"; 264 | PRODUCT_NAME = "$(TARGET_NAME)"; 265 | }; 266 | name = Release; 267 | }; 268 | /* End XCBuildConfiguration section */ 269 | 270 | /* Begin XCConfigurationList section */ 271 | 528C95BB1C11207B00A81C7F /* Build configuration list for PBXProject "ClearCache-Swift" */ = { 272 | isa = XCConfigurationList; 273 | buildConfigurations = ( 274 | 528C95D01C11207B00A81C7F /* Debug */, 275 | 528C95D11C11207B00A81C7F /* Release */, 276 | ); 277 | defaultConfigurationIsVisible = 0; 278 | defaultConfigurationName = Release; 279 | }; 280 | 528C95D21C11207B00A81C7F /* Build configuration list for PBXNativeTarget "ClearCache-Swift" */ = { 281 | isa = XCConfigurationList; 282 | buildConfigurations = ( 283 | 528C95D31C11207B00A81C7F /* Debug */, 284 | 528C95D41C11207B00A81C7F /* Release */, 285 | ); 286 | defaultConfigurationIsVisible = 0; 287 | }; 288 | /* End XCConfigurationList section */ 289 | }; 290 | rootObject = 528C95B81C11207B00A81C7F /* Project object */; 291 | } 292 | -------------------------------------------------------------------------------- /ClearCache-Swift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ClearCache-Swift.xcodeproj/project.xcworkspace/xcuserdata/huchunyuan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lafree317/ClearCache-Swift/a29c53948cbf38afe977fb6ab8537634880a9297/ClearCache-Swift.xcodeproj/project.xcworkspace/xcuserdata/huchunyuan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ClearCache-Swift.xcodeproj/xcuserdata/huchunyuan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ClearCache-Swift.xcodeproj/xcuserdata/huchunyuan.xcuserdatad/xcschemes/ClearCache-Swift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ClearCache-Swift.xcodeproj/xcuserdata/huchunyuan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ClearCache-Swift.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 528C95BF1C11207B00A81C7F 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ClearCache-Swift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ClearCache-Swift 4 | // 5 | // Created by huchunyuan on 15/12/4. 6 | // Copyright © 2015年 huchunyuan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ClearCache-Swift/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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ClearCache-Swift/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 | 29 | -------------------------------------------------------------------------------- /ClearCache-Swift/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /ClearCache-Swift/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 | 40 | 41 | -------------------------------------------------------------------------------- /ClearCache-Swift/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ClearCache-Swift 4 | // 5 | // Created by huchunyuan on 15/12/4. 6 | // Copyright © 2015年 huchunyuan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | } 17 | 18 | @IBAction func alertAction(sender: UIButton) { 19 | // 取出cache文件夹路径 20 | let cachePath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomainMask.UserDomainMask, true).first 21 | // 打印路径,需要测试的可以往这个路径下放东西 22 | print(cachePath) 23 | // 取出文件夹下所有文件数组 24 | let files = NSFileManager.defaultManager().subpathsAtPath(cachePath!) 25 | // 用于统计文件夹内所有文件大小 26 | var big = Int(); 27 | 28 | 29 | // 快速枚举取出所有文件名 30 | for p in files!{ 31 | // 把文件名拼接到路径中 32 | let path = cachePath!.stringByAppendingFormat("/\(p)") 33 | // 取出文件属性 34 | let floder = try! NSFileManager.defaultManager().attributesOfItemAtPath(path) 35 | // 用元组取出文件大小属性 36 | for (abc,bcd) in floder { 37 | // 只去出文件大小进行拼接 38 | if abc == NSFileSize{ 39 | big += bcd.integerValue 40 | } 41 | } 42 | } 43 | 44 | // 提示框 45 | let message = "\(big/(1024*1024))M缓存" 46 | let alert = UIAlertController(title: "清除缓存", message: message, preferredStyle: UIAlertControllerStyle.Alert) 47 | 48 | let alertConfirm = UIAlertAction(title: "确定", style: UIAlertActionStyle.Default) { (alertConfirm) -> Void in 49 | // 点击确定时开始删除 50 | for p in files!{ 51 | // 拼接路径 52 | let path = cachePath!.stringByAppendingFormat("/\(p)") 53 | // 判断是否可以删除 54 | if(NSFileManager.defaultManager().fileExistsAtPath(path)){ 55 | // 删除 56 | do { 57 | try NSFileManager.defaultManager().removeItemAtPath(path) 58 | } catch let error as NSError { 59 | print(error) 60 | } 61 | 62 | } 63 | } 64 | } 65 | alert.addAction(alertConfirm) 66 | let cancle = UIAlertAction(title: "取消", style: UIAlertActionStyle.Cancel) { (cancle) -> Void in 67 | 68 | } 69 | alert.addAction(cancle) 70 | // 提示框弹出 71 | presentViewController(alert, animated: true) { () -> Void in 72 | 73 | } 74 | } 75 | 76 | override func didReceiveMemoryWarning() { 77 | super.didReceiveMemoryWarning() 78 | 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ClearCache-Swift 2 | iOS-Swift-清理缓存 3 | #前言 4 | ####swift现在网上资源比较乱,需要找的要找很久,于是自己开始整理自己遇到的功能开始swift化,如果效果不错的话以后就会一直发表swift的博客,所以请各位读者多给我的GitHub点几个Star吧! 5 | --- 6 | #效果图 7 | ![这里写图片描述](http://img.blog.csdn.net/20151204133231461) 8 | #上代码 9 | ####在storyBoard创建一个button关联点击事件,然后在ViewController里写上以下代码 10 | ``` 11 | import UIKit 12 | 13 | class ViewController: UIViewController { 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | } 19 | 20 | @IBAction func alertAction(sender: UIButton) { 21 | // 取出cache文件夹路径 22 | let cachePath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomainMask.UserDomainMask, true).first 23 | // 打印路径,需要测试的可以往这个路径下放东西 24 | print(cachePath) 25 | // 取出文件夹下所有文件数组 26 | let files = NSFileManager.defaultManager().subpathsAtPath(cachePath!) 27 | // 用于统计文件夹内所有文件大小 28 | var big = Int(); 29 | 30 | 31 | // 快速枚举取出所有文件名 32 | for p in files!{ 33 | // 把文件名拼接到路径中 34 | let path = cachePath!.stringByAppendingFormat("/\(p)") 35 | // 取出文件属性 36 | let floder = try! NSFileManager.defaultManager().attributesOfItemAtPath(path) 37 | // 用元组取出文件大小属性 38 | for (abc,bcd) in floder { 39 | // 只去出文件大小进行拼接 40 | if abc == NSFileSize{ 41 | big += bcd.integerValue 42 | } 43 | } 44 | } 45 | 46 | // 提示框 47 | let message = "\(big/(1024*1024))M缓存" 48 | let alert = UIAlertController(title: "清除缓存", message: message, preferredStyle: UIAlertControllerStyle.Alert) 49 | 50 | let alertConfirm = UIAlertAction(title: "确定", style: UIAlertActionStyle.Default) { (alertConfirm) -> Void in 51 | // 点击确定时开始删除 52 | for p in files!{ 53 | // 拼接路径 54 | let path = cachePath!.stringByAppendingFormat("/\(p)") 55 | // 判断是否可以删除 56 | if(NSFileManager.defaultManager().fileExistsAtPath(path)){ 57 | // 删除 58 | try! NSFileManager.defaultManager().removeItemAtPath(path) 59 | } 60 | } 61 | } 62 | alert.addAction(alertConfirm) 63 | let cancle = UIAlertAction(title: "取消", style: UIAlertActionStyle.Cancel) { (cancle) -> Void in 64 | 65 | } 66 | alert.addAction(cancle) 67 | // 提示框弹出 68 | presentViewController(alert, animated: true) { () -> Void in 69 | 70 | } 71 | } 72 | 73 | ``` 74 | 75 | #效果展示 76 | ![这里写图片描述](http://img.blog.csdn.net/20151204133445628) 77 | 78 | ##GitHub:https://github.com/Lafree317/ClearCache-Swift 79 | --- 80 | 本人还是一只小菜鸡,不过是一只热心肠的菜鸡,如果有需要帮助或者代码中有更好的建议的话可以发邮件到lafree317@163.com中,我们一起进步XD 81 | --------------------------------------------------------------------------------