Post

Replies

Boosts

Views

Activity

Trouble with url?.pathExtension
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?
2
0
653
Jan ’20
Tif Image causing memory leaks
I have a list of images from my app budle in a tableview, when I select one a view controller/imageview opens with the image. When the view is closed via navcontroller back button I am getting serious memory leaks. The leaks are in the 100mb size. I have used instruments leaks and it seems to only leak when a large Tiff image is rendered and then closed. The call to " 1 ImageIO invocation function for block in TIFFReadPlugin::DecodeBlocks(IIOImageRead*, GlobalTIFFInfo*, ReadPluginData const&, TIFFPluginData" seems to be the culprit. JPG and PNG and small Tif files don't seem to leak. Any Ideas?
0
0
499
Oct ’20
why is UIImage(contentsOfFile: "path") retaining memory
The memory used jumps to 498 megs when image is loaded but not displayed and drops to 242 megs when viewcontroller is dropped with nav controllers back button. UIImage(contentsOfFile: is not supposed to cache, i assume that is where the 240 meg drop is from, but why is half of memory used, 240 megs, being retained? func  save_ImageJPG() -> Bool {         // load tif from app folder image approx 8000 x 6000 pixels         let s  = currentMap_Name.replacingOccurrences(of: " ", with: "%20")         let filePath = getDocumentsDirectory().appendingPathComponent("Folder" ).appendingPathComponent(s)         let image = UIImage(contentsOfFile: filePath.path)         // change file type to jpg         let f = URL(string: s)?.deletingPathExtension().absoluteString         let e = URL(string: f! + ".jpg")?.absoluteString         let path = getDocumentsDirectory().appendingPathComponent("TempFolder"         ).appendingPathComponent(e!)         if !FileManager.default.fileExists(atPath: path.path) {             let jpgData = (image!.jpegData(compressionQuality: 1.0)!)             try? jpgData.write(to: path)             return true         }             return false     } or is the let jpgData = (image!.jpegData(compressionQuality: 1.0)!) retaining memory?
3
0
812
Oct ’21
convert a non-http url to url
my iphone app downloads maps from a website which uses the following for the download link. col3 recImageMini lazy" style="background-image: url(/img4/usTopo_icons/Browse/ID/ID_Oden_Bay_20200415_TM_tn.jpg); Apparently fetch won't let my app download without the http(s) prefix. How can the link be captured so I can add a http prefix? The links work okay when using a browser on iPad/phone/imac but not when using WKWebkit. Thanks
0
0
431
Nov ’21
UIActivityViewController warning/errors
This is a simple test file sharing which I cannot find info on. the "(This will become a fault soon.)" from xcode is what is the worrisome, it seems to have developed recently with xcode update? I don't want to release an app which may soon fail. class ShareFile_ViewController: UIViewController {     override func viewDidLoad() {       super.viewDidLoad()             navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Share", style: .plain, target: self, action: #selector(shareFile))         }        @objc func shareFile() {             if let fileURL = Bundle.main.url(forResource: "Skiing", withExtension: "gpx") { let ac = UIActivityViewController(activityItems: [fileURL], applicationActivities: nil) present(ac, animated: true, completion: nil)             }        } } // this error has been beat to death as don't worry about it. 2022-02-19 16:28:47.644274-0800 ShareFile_Learn[36671:12674168] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]} // this warning is my concern since it says it become a fault soon, should I worry about this? 2022-02-19 16:28:47.644370-0800 ShareFile_Learn[36671:12674168] [default] -imageForImageDescriptor: can do IO please adopt -imageForDescriptor: for IO free drawing or -prepareImageForDescriptor: if IO is allowed. (This will become a fault soon.)
2
0
1k
Feb ’22