Iterate through files in a folder and its subfolders using Swift’s FileManager

Use the nextObject() method of enumerator:

while let element = enumerator?.nextObject() as? String {
    if element.hasSuffix("ext") { // checks the extension
    }
}

Leave a Comment