Usually used to delete the cache, calculate the cache size // the size of a single file-(long) fileSizeAtPath :( NSString *) filePath {NSFileManager * manager = [NSFileManager defamanager]; if ([manager fileExistsAtPath: filePath]) {return [[manager attributesOfItemAtPath: filePath error: nil] fileSize];} return 0;} traverse the folder to get the folder size, how many M-(float) folderSizeAtPath :( NSString *) folderPath {NSFileManager * manager = [NSFileManager defaultManager]; if (! [Manager fileExistsAtPath: folderPath]) return 0; NSEnumerator * childFilesEnumerator = [[manager subpathsAtPath: folderPath] objectEnumerator]; NSString * fileName; long folderSize = 0; while (fileName = [childFilesEnumerator nextObject])! = Nil) {NSString * fileAbsolutePath = [folderPath stringByAppendingPathComponent: fileName]; folderSize + = [self fileSizeAtPath: fileAbsolutePath];} return folderSize/(1024.0*1024.0 );}