I have code as follows:

let fileManager = FileManager.default
do {
try fileManager.createDirectory(at: destination.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: nil)
    try fileManager.copyItem(at: source, to: destination)
    handler(true, nil)
}
catch let theError as NSError {
    if theError.code == NSFileWriteNoPermissionError {
        ...
    }
    else {
        ...
    }
}
catch {
     handler(false, NSError(...))
}

Running on macOS 10.12.6, Xcode 8.3.2, I get to the copyItem call, which shows an error on the console:

2017-11-11 11:18:25.931446+1000 MyApp[32662:2408351] open on /path/to/file: Permission denied

But it doesn't go to either of my catch blocks, but goes to the following line, where the completion handler is to be run. What is going on?

John
--
John Brownie
SIL-PNG, Ukarumpa, Eastern Highlands, Papua New Guinea
Mussau-Emira language, New Ireland Province, Papua New Guinea
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to