When using Swift, I want to check if the location is a NSURLdirectory. With Objective-C, this is not a problem and a working find, but when I convert the code to Swift, I run a runtime error.
Can someone point me in the right direction?
import Foundation
let defaultManager = NSFileManager.defaultManager()
let documentsDirectory = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
let localDocumentURLs = defaultManager.contentsOfDirectoryAtURL(documentsDirectory,
includingPropertiesForKeys: nil, options: .SkipsPackageDescendants, error: nil) as NSURL[]
for url in localDocumentURLs {
var isError: NSError? = nil
var isDirectory: AutoreleasingUnsafePointer<AnyObject?> = nil
var success: Bool = url.getResourceValue(isDirectory, forKey: NSURLIsDirectoryKey, error: &isError)
}
source
share