Posts

Post not yet marked as solved
3 Replies
3 years later - Xcode 15.0 - Still Buggy ✓ Conversion from UnitAngle.degrees to UnitAngle.arcMinutes and UnitAngle.arcSeconds are still buggy (at least in macOS playground, I don't which version of Foundation it is uses)
Post not yet marked as solved
1 Replies
Note that when it happens, the "Share albums..." feature in the Apple Music app may not work (which is a shame): it will send an empty email for instance, instead of the share url. In other cases, the share link works, and it contains the CatalogId. When the share link works, you can retrieve the album catalogId by using the first song of the song of the album which will contain its catalogId in the playparams struct. Querying the song will then gives you the album catalogId. When the share links does not work, the catalogId of the songs does not work. For instance this catalogId does not work for me (storefront "fr"): "playParams": { "id": "i.AWPK6FLXMqL4", "kind": "song", "isLibrary": true, "reporting": true, "catalogId": "392108251", "reportingId": "392108251" }
Post not yet marked as solved
12 Replies
Same here with Xcode Version 13.0 (13A233).
Post not yet marked as solved
94 Replies
Is there a way to reproduce the issue reliably.I mean make a working device have the bug.Because a lot of solutions seem to come down to the reinstalling step updating the system list until another app update make it fails again.
Post not yet marked as solved
31 Replies
can't get/set current scroll position in a List (or ScrollView)
Post not yet marked as solved
8 Replies
From the tests I've made, it seems to load only the displayed items.
Post not yet marked as solved
24 Replies
I don't reproduce the problem in the simulator with 10 or less items and I am short on devices to run the betas.That said, I am not sure where the fetch should be done, maybe "onAppear" is not the best place. Originally I took it from a sample here:https://mecid.github.io/2019/07/03/managing-data-flow-in-swiftui/Maybe, the functional way would be to do it lazily when the fetched results controller is accessed.
Post not yet marked as solved
24 Replies
I have pasted a lot of code below but the secret sauce here is to use .objectID in line 43 as an identifier instead of your own attribute so that the faults are not fired until the cell is displayed via onAppear at line 21.Below I am using the fetchedObjects property from NSFetchedResultsController but it would work with the result array of a simple query.//MARK: The Model public class POI: NSManagedObject, BindableObject { public let willChange = PassthroughSubject<void, never="">() public override func awakeFromFetch() { print("\(name) realized") self.willChange.send() } public func fire() { let _ = self.name } } //MARK: The cell struct POIRow: View { @ObjectBinding var poi: POI var body: some View { HStack { Text(name) }.onAppear { self.poi.fire() } } var name:String { let name:String if poi.isFault { name = "Please wait..." //never displayed in practice } else if let poiname = poi.name { name = poiname } else { name = "no name, no slogan" //should not happen } return name } } //MARK: The view struct TestView : View { @ObjectBinding var store:POIStore = POIStore(context:(UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext) var body: some View { NavigationView { List(store.places, id:\.objectID) { (poi:POI) in POIRow(poi:poi) } .onAppear { self.store.performFetch() } } } } #if DEBUG struct TestView_Previews: PreviewProvider { static var previews: some View { TestView() } } #endif class POIStore: NSObject, BindableObject, NSFetchedResultsControllerDelegate { let willChange = PassthroughSubject<void, never="">() let context:NSManagedObjectContext init(context:NSManagedObjectContext) { self.context = context } var places:[POI] { return self.fetchedResultsController.fetchedObjects ?? [POI]() } //MARK: NSFetchedResultController fileprivate lazy var fetchedResultsController: NSFetchedResultsController = { let fetchRequest: NSFetchRequest = POI.fetchRequest() fetchRequest.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)] let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.context, sectionNameKeyPath: nil, cacheName: nil) fetchedResultsController.delegate = self return fetchedResultsController }() func controllerWillChangeContent(_ controller: NSFetchedResultsController) { self.willChange.send() } func performFetch() { do { try self.fetchedResultsController.performFetch() self.willChange.send() } catch { fatalError("Failed to fetch entities: \(error)") } } }
Post not yet marked as solved
24 Replies
Here is a method which seems to work with Xcode 11 Beta 4. I have created 50000 and displayed them in a List by binding the result of a fetch request without having the 50000 faults being fired.I use SwiftUI List with the .objectIDproperty as id instead of implementing Identifiable:List(myStore.arrayOfManagedObjects, id:\.objectID)Then in my cell View, I fire the fault in onAppear by accessing a property of the NSManagedObject.My NSManagedObject implements BindableObject so that when it is realized from database (awakeFromFetch), willchange is send and the cell view is refreshed.It seems to work. Will post code later if requested.