JohnSundell / Files

A nicer way to handle files & folders in Swift
MIT License
2.53k stars 182 forks source link

Examples are buggy #106

Closed DevyV closed 4 years ago

DevyV commented 4 years ago

Hello,

As a new to Swift developer, I found your great code when trying to manipulate files!

With my Swift knowledge being not so shiny so far, my problem is that your example codes generate errors in Xcode (Version 11.3.1), so they just cannot be build and run.

E.g you wrote:

Move all files in a folder to another:

let originFolder = try Folder(path: "/users/john/folderA")
let targetFolder = try Folder(path: "/users/john/folderB")
try originFolder.files.move(to: targetFolder)

Now Xcode gives me the same error at all the above lines:

Errors thrown from here are not handled.

So what is the proper coding to use Files? E.g. what is the full code to move all files in a folder to another? Could you put it down it, please?

Thanks a lot in advance! Devy

LarsJK commented 4 years ago

Wrap it in a do-catch.

https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html

DevyV commented 4 years ago

Yes, I figured it myself after 2 hours of searching for a solution.

As a new-to-swift guy, it was also quite frustrating to get errors in Xcode me when trying to deal with your samples, since a simple copy+paste should work for examples I believe.

So why do not you publish sample code that work just out-of-the box? May that help far too much for readers like new swift learners?