Post

Replies

Boosts

Views

Activity

Update to UITableViewDiffableDataSource row
When an instance var of an object changes value then the new state is not shown by the UITableView with a UITableViewDiffableDataSource after the call to dataSource.apply(snapshot).Is there a way for an update/change flag to work on objects in a UITableViewDiffableDataSource?This is mentioned in the https://forums.developer.apple.com/thread/120320 where developers found that changes in fields do not show as the uniqueIdentifiers have not changed in the object.I have found that the object with a instance var change must be deleted from the items in the datasource.snapshot and added with a new unique identifier. Here's some psuedo code to illustrate the behaviourvar snapshot = dataSource.snapshot() updateItem = dataSource.itemIdentifier(for: changedRow) updateItem.stateVar = true dataSource.apply(snapShot)The new state is not shown in the UIInstead to make the new state show I have to remove the old item, copy to a new instance with a new unique identifier, update the state. Then remove the old item from the snapshot and insert the new item.Clearly creating a complete new snapshot instead of copy/change of the existing snapshot would show the new object state. However when only one row of a large dataSource is changed there is a performance problem.Psuedo code that makes the new state showvar snapshot = dataSource.snapshot() updateItem = dataSource.itemIdentifier(for: changedRowPath) updateItem.stateVar = true // make a copy of the updateItem with a new uniqueIdentifier newbieItem = updateItem.clone() // now get the postion prior item in the snapshot priorRow = max(changedRowPath.row - 1, 0) priorItemIndex = IndexPath(row: priorRow, section: changeRowPath.section) priorItem = dataSource.itemIdentifier(for: priorItemIndex) // delete updateItem snapshot.deleteItems([updateItem] snapshot.insertItems([newbieItem], afterItem: priorItem) // now apply with new clone and the changed value dataSource.apply(snapShotDid I miss a simple way to change one row of a dataSource? Or how should this be handled?
1
0
1.5k
May ’20
User albums can not be accessed
Why would user created albums be cut off from app access ? ”User albums however can not be fetched” If the user created the album then they “should “ be able to pick or use the album within a photo editing app, right? The user has decided to organize their images according to their own criteria.. The user created their own system of image selection in an album. It is mystifying to me that user can not access their own album from an app. My first impression is that this decision should be reviewed! My app is built around loading the user created album ( as selected by the user”) so this is a profound effect.
2
0
662
Jun ’20
Persistence of photo access permission ?
I understand that when the user picks a set of images in the PKPicker mode on the Library object then the usual attributes such as local identifier are returned in the query. If an app stores the local identifiers, can the app load the images in another session with just the local identifier? i.e. is the user permission persistent for later requests via a query on the Photo Libary?
4
0
1.3k
Jun ’20
CIKMeans filter - Example or documentation ?
iOS 13 introduced CIFilter "CIKMeans" which is used by the related CIPaletteCentroid  and CIPalettize filters. Are there any examples of the use of CIKMeans? I am mystified by the CIKMeans error "Mean seeds should be passed as a K x 1 image.." I am using a CIImage as the input for the inputMeans parm. The inputMeans attribute has this in the parmDictionary   ▿ 3 elements  ▿ 0 : 2 elements   - key : "CIAttributeDescription"   - value : Specifies the color seeds to use for k-means clustering, either passed as an image or an array of colors.  ▿ 1 : 2 elements   - key : "CIAttributeClass"   - value : CIImage  ▿ 2 : 2 elements   - key : "CIAttributeDisplayName"   - value : Means" What is a CIImage that qualifies as a "K x 1" image?
2
0
1.7k
Aug ’20
PHPickerViewController enhancement: show assets previously selected
When a user picks asset(s) from the PickerView there should be an interface to return the user to the same album and asset. i.e. the PickerView should show the photoLibrary the way the user left it. This would remove the 'friction' of navigating to the same album when the user is making a change in their selection. In large or deep photoLibraries it is easy to lose track of the spot where a picture was found. In particular the PHPickerResult should return to the app the assetCollection localIdentifier, along with the asset localIdentifier. support an interface for passing the assetCollection and asset localIdentifier(s) to navigate to the same photo library location on the initial open. I would love to use PHPickerViewController as it could replace a significant amount of picking views and code in a photo filter app. But it needs a way to restore the visual state instead of searching again on every image pick. Thanks !! p.s. Is there a better way to submit enhancement requests (such as a bug report)?
1
0
1k
Feb ’21
xCode 13 install causes iMac reboot
My new iMac is rebooting about half way into the installing phase of xCode 13. Many attempts.. always the same crash A Feedback Assistant bug report has been filled. I can restore the last version of xCode from backup Any ideas for a work around? Obviously no new app releases from me until xCode is running again at the 13 version
2
0
1k
Sep ’21
PHPhoto localIdentifier to cloudIdentifier conversion
The sample code in the Apple documentation found in  PHCloudIdentifier does not compile in xCode 13.2.1. Can the interface for identifier conversion be clarified so that the answer values are more accessible/readable. The values are 'hidden' inside a Result enum It was difficult (for me) to rewrite the sample code because I made the mistake of interpreting the Result type as a tuple. Result type is really an enum. Using the Result type as the return from library.cloudIdentifierMappings(forLocalIdentifiers: ) and .localIdentifierMappings( for: ) puts the actual mapped identifiers inside the the enum where they need additional access via a .stringValue message or an evaluation of an element of the result enum. For others finding the same compile issue, here is a working version of the sample code. This compiles in xCode 13.2.1. func localId2CloudId(localIdentifiers: [String]) -> [String] {         var mappedIdentifiers = [String]()        let library = PHPhotoLibrary.shared()         let iCloudIDs = library.cloudIdentifierMappings(forLocalIdentifiers: localIdentifiers)         for aCloudID in iCloudIDs {           let cloudResult: Result = aCloudID.value             // Result is an enum .. not a tuple             switch cloudResult {                 case .success(let success):                     let newValue = success.stringValue                     mappedIdentifiers.append(newValue)                 case .failure(let failure):                     // do error notify to user                       }         }         return mappedIdentifiers     } ``` swift func func cloudId2LocalId(assetCloudIdentifiers: [PHCloudIdentifier]) -> [String] {             // patterned error handling per documentation         var localIDs = [String]()         let localIdentifiers: [PHCloudIdentifier: Result<String, Error>]  = PHPhotoLibrary.shared() .localIdentifierMappings(                   for: assetCloudIdentifiers)         for cloudIdentifier in assetCloudIdentifiers {             guard let identifierMapping = localIdentifiers[cloudIdentifier] else {                 print("Failed to find a mapping for \(cloudIdentifier).")                 continue             }             switch identifierMapping {                 case .success(let success):                     localIDs.append(success)                 case .failure(let failure) :                     let thisError = failure as? PHPhotosError                     switch thisError?.code {                         case .identifierNotFound:                             // Skip the missing or deleted assets.                             print("Failed to find the local identifier for \(cloudIdentifier). \(String(describing: thisError?.localizedDescription)))")                         case .multipleIdentifiersFound:                             // Prompt the user to resolve the cloud identifier that matched multiple assets.                             print("Found multiple local identifiers for \(cloudIdentifier). \(String(describing: thisError?.localizedDescription))") //                            if let selectedLocalIdentifier = promptUserForPotentialReplacement(with: thisError.userInfo[PHLocalIdentifiersErrorKey]) { //                                localIDs.append(selectedLocalIdentifier)                         default:                             print("Encountered an unexpected error looking up the local identifier for \(cloudIdentifier). \(String(describing: thisError?.localizedDescription))")                     }               }             }         return localIDs     }
0
0
608
Feb ’22
validateCurrentFocusedItemForAppearingEnvironment ??
Sometimes the log has this cryptic message. Any ideas on what action is needed, or how to implement the 'should have cancelled validation' that is referenced in the message? "[Assert] Somehow we ended up in _validateCurrentFocusedItemForAppearingEnvironment even though there is no focused item. We should have cancelled the validation request in that case."
1
0
750
Jun ’22
PHPickerViewController in limited library mode
In the case where an app uses the Photo Library to reload images by using a fetchRequest with localIdentifier there is hole in the following guidance in WWDC21 "Improve access to Photos in your app" "When the picker session is completed, selected photos will be returned to your app. Suppose the configuration is initialized with a PHPhotoLibrary object, picker results will contain both item providers and asset identifiers. Your app can use the item provider to load and display selected photos." The picker result providers do not load the image if the image is not in the limited library list, even though the user has selected them with the PHPicker. It looks like the workaround is to raise a user error that the image is not loaded because it is not in the limited selection, then do the PHPhotoLibrary.shared().presentLimitedLibraryPicker so the limited selection is the way the user wants it. This workaround seems like an awful thing to do to the user since they have to pick the same photo(s) twice.. Also - this scenario works fine with the PHPickerDemo because privacy setting for the demo is not added in settings.. Presumably because PHPickerDemo is not directly using the PhotoKit API methods. Any thoughts or workaround alternatives that you see? Or raise a bug? Thanks!!
1
0
828
Jul ’22
CoreData result class has 'Sendable' warnings
In an iOS viewController, I use the NSDiffableDataSource to populate a tableView from the results of a CoreData fetchController. The result class is defined by CoreData - in this case a class named CDFilterStack. In xCode 16.0 Beta with strict concurrency checking = 'Complete' the CDFilterStack class has this warning everywhere it is referenced. "Type 'CDFilterStack' does not conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode." The class definition of CDFilterStack is not editable because it is generated by CoreData. I think I need to mark this class (and other similar classes) as @preconcurrency... but how & where? Here's one method sample that generates three of these warnings func initialSnapShot() -> NSDiffableDataSourceSnapshot<Int, CDFilterStack> { var snapshot = NSDiffableDataSourceSnapshot<Int, CDFilterStack>() if let sections = dataProvider.fetchedResultsController.sections { for index in 0..<sections.count { let thisSection = sections[index] guard let sectionStacks = thisSection.objects as? [CDFilterStack] else { continue} snapshot.appendSections([index]) snapshot.appendItems(sectionStacks) } // for loop that will continue on error in objects } return snapshot } Careful reading of the various migration guides hasn't produced an example of how to handle this.. (btw the migration guides are nicely done:)
1
0
432
Jun ’24