Swift 3.0计算缓存和清理缓存

2017-03-03  本文已影响122人  Johnny_Chang

地址

http://www.qingpingshan.com/rjbc/swift/167567.html

http://www.cnblogs.com/madarax/p/6203567.html

自己写的:

//统计缓存大小

letdataPath =NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory,FileManager.SearchPathDomainMask.userDomainMask,true).first

letfileManager =FileManager.default

letfiles = fileManager.subpaths(atPath: dataPath!)

print(files)

varDocSize:UInt64=0

forfileinfiles!{

iffile.hasSuffix("mp4")||file.hasSuffix("MP4")||file.hasSuffix("Mp4"){

letpath = dataPath!+"/\(file)"

do{

letfloder:NSDictionary=try!fileManager.attributesOfItem(atPath: path)asNSDictionary

//判断后缀是否为MP4,MP3,ACC

print(floder)

DocSize += floder.fileSize()

}catch_{

}

}

}

上一篇下一篇

猜你喜欢

热点阅读