Post

Replies

Boosts

Views

Activity

Reply to SWIFT TASK CONTINUATION MISUSE - leaked its continuation!
func saveAndCloseWithCompletionHandler(_ onCompletion :((Bool) -> Void)?) { self.prepareForClosing(); self.saveDocument { (saveSuccess) in if(saveSuccess) { self.closeDocument(completionHandler: { (_) in onCompletion?(saveSuccess); }); } else { onCompletion?(saveSuccess); } } } func prepareForClosing() { #if !NS2_SIRI_APP //save local meta data cache self.localCacheWrapper?.saveMetadataCache(); self.deleteUnusedFileItems(); #endif } func saveDocument(completionHandler : ((Bool) -> Void)?) { if(self.openPurpose == .read) { completionHandler?(true); return; } if(self.hasAnyUnsavedChanges) { (self.delegate as? FTNoteshelfDocumentDelegate)?.documentWillStartSaving(self); } #if !NS2_SIRI_APP self.recognitionCache?.saveRecognitionInfoToDisk(forcibly: true); if(self.hasAnyUnsavedChanges) { if let cache = self.recognitionCache, let cachePlist = cache.recognitionCachePlist() { let mutableDict = NSMutableDictionary.init(dictionary: cachePlist.contentDictionary); self.recognitionInfoPlist()?.updateContent(mutableDict); } if let cache = self.recognitionCache, let cachePlist = cache.visionRecognitionCachePlist() { let mutableDict = NSMutableDictionary.init(dictionary: cachePlist.contentDictionary); self.visionRecognitionInfoPlist()?.updateContent(mutableDict); } //This was added in version 6.2, when we removed the bounding rect from the Segment level storage. updateDocumentVersionToLatest() } #endif super.save { (success) in if(success) { self.previousFileModeificationDate = self.fileModificationDate; let pages = self.pages(); for eachPage in pages { eachPage.isDirty = false; } } completionHandler?(success); } } func closeDocument(completionHandler: ((Bool) -> Void)?) { #if !NS2_SIRI_APP self.recognitionCache?.saveRecognitionInfoToDisk(forcibly: true) #endif super.close { (success) in self.removeObservers(); completionHandler?(success); } } // in above function, super is --> UIDocument
Jun ’23
Reply to Crash in iOS18
I had similar issue with iOS18.(issue exists in below code) func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FTShelfTagsPageCell", for: indexPath) as? FTShelfTagsPageCell else { return UICollectionViewCell() } cell.selectionBadge?.isHidden = viewState == .none ? true : false if indexPath.section == 0 { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FTShelfTagsBooksCell", for: indexPath) as? FTShelfTagsBooksCell else { return UICollectionViewCell() } return cell } else if indexPath.section == 1 { let item = pages[indexPath.row] cell.updateTagsItemCellContent(tagsItem: item, isRegular: self.traitCollection.isRegular) } cell.isSelected = true return cell } It is dequeuing 2 cells though I return single cell. After simplification like below, issue got fixed. (only 1 cell ll be dequeued at a time.) func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { if indexPath.section == 0 { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FTShelfTagsBooksCell", for: indexPath) as? FTShelfTagsBooksCell else { return UICollectionViewCell() } return cell } else { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FTShelfTagsPageCell", for: indexPath) as? FTShelfTagsPageCell else { return UICollectionViewCell() } let item = pages[indexPath.row] cell.selectionBadge?.isHidden = viewState == .none ? true : false cell.updateTagsItemCellContent(tagsItem: item, isRegular: self.traitCollection.isRegular) cell.isSelected = true return cell } }
Jul ’24