Searching for tif files in my project bundle was only returning one of 5 files using this code:
var pictures = [String]()
let fm = FileManager.default
let path = Bundle.main.resourcePath!
let items = try! fm.contentsOfDirectory(atPath: path)
var url: URL?
for item in items {
url = URL(string: item)
if url?.pathExtension == "tif" {
print("tif found")
print(item)
pictures.append(item)
}
}
These five files are in resource folder of project.
["ID_Dodge Peak_235936_1967_24000_geo.tif", "Base.lproj", "LargeImages", "ID_Benning Mountain_235241_1996_24000_geo.tif", "_CodeSignature", "META-INF", "Frameworks", "ID_Colburn_235747_1996_24000_geo.tif", "Info.plist", "libswiftRemoteMirror.dylib", "ID_Clark Fork_235695_1996_24000_geo.tif", "PkgInfo", "Assets.car", "embedded.mobileprovision", "ID_Clifty_Mountain_235717_1996_24000_geo.tif"]
The search was only finding "ID_Colburn_235747_1996_24000_geo.tif".
After looking at other files, I realized the other file names had spaces, so they weren't being found.
When I added an underscore to complete other names, they were also found.
Question is why?