Post

Replies

Boosts

Views

Activity

Func fileExists finds .json but not .jpg files
The func fileExists finds .json file but not .jpg files in the same directory!(User-names were find/replaced with “Name” & “name”)What am I missing?This new swift user Thanks You!CODE:func fileExists(url: URL) -> Bool { do { let fileManager = FileManager.default try fileManager.fileExists(atPath: String(contentsOf: url)) } catch { return false } return true} fileprivate func _guaranteeImage(name: String) -> _ImageDictionary.Index { if let index = images.index(forKey: name) { return index } if fileExists(url: trailDataURL) {print("\(trailDataURL)")} let url = trailFileURL.appendingPathComponent("\(name).jpg")//TODO not working! print("\(url)") if fileExists(url: url) { images[name] = ImageStore.reloadImage(url: url) } else { images[name] = ImageStore.loadImage(name: name) } return images.index(forKey: name)! }DIRECTORY form terminal:Name-iMac:~ name$ cd ///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/DocumentsName-iMac:Documents name$ ls -ltotal 848-rw-r--r-- 1 name staff 63243 Feb 5 16:49 chilkoottrail.jpg-rw-r--r-- 1 name staff 52721 Feb 5 15:08 margarette-falls.jpg-rw-r--r-- 1 name staff 309101 Feb 5 16:48 silversalmoncreek.jpg-rw-r--r-- 1 name staff 1249 Feb 6 07:41 trailData.jsonName-iMac:Documents name$PRINT RESULTS (from iPhone 8 Simulator):file:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/0AF1262C-7894-4408-A873-D91B17A3B6E4/Documents/trailData.jsonfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/0AF1262C-7894-4408-A873-D91B17A3B6E4/Documents/margarette-falls.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Bundle/Application/D00EAD3D-B118-4C8B-A90D-177D9419D989/LocalTrails.app/margarette-falls.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/0AF1262C-7894-4408-A873-D91B17A3B6E4/Documents/trailData.jsonfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/0AF1262C-7894-4408-A873-D91B17A3B6E4/Documents/silversalmoncreek.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Bundle/Application/D00EAD3D-B118-4C8B-A90D-177D9419D989/LocalTrails.app/silversalmoncreek.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/0AF1262C-7894-4408-A873-D91B17A3B6E4/Documents/trailData.jsonfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/0AF1262C-7894-4408-A873-D91B17A3B6E4/Documents/chilkoottrail.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Bundle/Application/D00EAD3D-B118-4C8B-A90D-177D9419D989/LocalTrails.app/chilkoottrail.jpgCODE (only logic reversed then App re-run):if !fileExists(url: url) {PRINT RESULTS (from iPhone 8 Simulator):file:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/trailData.jsonfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/margarette-falls.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/margarette-falls.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/trailData.jsonfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/silversalmoncreek.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/silversalmoncreek.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/trailData.jsonfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/chilkoottrail.jpgfile:///Users/name/Library/Developer/CoreSimulator/Devices/3AD300AB-EA56-4877-AD85-C117E5CE240F/data/Containers/Data/Application/5FEF88CA-E84E-4F4B-981B-EEDDF061FB95/Documents/chilkoottrail.jpg
6
0
802
Feb ’20