folder'in içerisindeki her bir dosyanın yolunu bir loop kullananrak bulup teker teker silmelisiniz.
let fileManager = NSFileManager.defaultManager()
let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
let fullPath = paths[0].stringByAppendingPathComponent("myFolder")
var fullPathItemIsADirectory:ObjCBool = false
if fileManager.fileExistsAtPath(fullPath, isDirectory: &fullPathItemIsADirectory) {
if fullPathItemIsADirectory {
var error:NSError?
for itemPath in fileManager.contentsOfDirectoryAtPath(fullPath, error: &error) as! [String] {
let fullItemPath = fullPath.stringByAppendingPathComponent(itemPath)
if fileManager.removeItemAtPath(fullItemPath, error: &error) {
println("item deleted at path:\(fullItemPath)")
} else {
if error != nil {
println("deletion error at path:\(fullItemPath) error:\(error!.localizedDescription)")
}
}
error = nil
}
} else {
println("item is not directory at path:\(fullPath)")
}
} else {
println("there is no such a directory at path:\(fullPath)")
}