i'm going nuts.
I'm trying to get the list of "txt" files from a folder but i get the list in the form of
Optional("Filename").txt
Here's my code, nothing fancy. I tried unwrapping the filename but the compiler gives me an error.I tried a "guard", a with "if", i tried "!" ... nothing works.
let enumerator:FileManager.DirectoryEnumerator = FileManager().enumerator(atPath: myFolderPath)!
while let element = enumerator.nextObject() as? String {
print(element)
if element.hasSuffix("txt") {
fileList.append(element)
}
}
I need to show this list in a table view.
I hope i'm not supposed to run trought the array and get the name of the files by using a bunch o string methods just to get rid of this text...
I'm not sure what can i do! I don't really want to use this solution:
Swift: Optional Text In Optional Value
Thank you