Created
May 7, 2015 22:17
-
-
Save KiGi/1be0197d9ef4ddfc9970 to your computer and use it in GitHub Desktop.
Swift 1.2 fileExistsAtPath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func checkIfFileExpired( fileURL : NSURL ) -> Bool { | |
let fileManager = NSFileManager() | |
if let fileManager.fileExistsAtPath(fileURL) { | |
var error : NSError? = nil | |
if let filePath = fileURL.path, | |
let fileAttr = fileManager.attributesOfItemAtPath(filePath, error: &error), | |
let creationDate = fileAttr[NSFileModificationDate] as? NSDate { | |
return creationDate.isBefore(NSDate.oneDayAgo()) | |
} else { | |
println("problem examining file attributes for \(fileURL): error was \(error)") | |
} | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment