http://www.qingpingshan.com/rjbc/swift/167567.html
http://www.cnblogs.com/madarax/p/6203567.html
自己寫的:
//統(tǒng)計緩存大小
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_{
}
}
}