Post

Replies

Boosts

Views

Activity

SectionedFetchRequest mixes up the sections
I am presenting a list of Items which are sections by the categoryIdentifier property. My app uses CloudKit. When I add change the categoryIdentifier for an item it is display in the correct section and other running instances of the app do the same. When restarting the app some items are grouped under an incorrect section, but the cstegoryIdentifier within the item is still as it was set. My question is what I'm doing wrong that upon restart the organization is incorrect. In case it matters, I'm setting this in the container:         container.viewContext.automaticallyMergesChangesFromParent = true As an aside: It seems necessary to make the sectioning type optional (as is the case in the underlying entity) like this SectionedFetchResults<String?, Item> Though the examples don't seem to need this. struct ContentView: View {     @Environment(\.managedObjectContext) private var viewContext     @State private var isShowingItem = false     @State private var isAddingItem = false          @SectionedFetchRequest(         sectionIdentifier: \.categoryIdentifier,         sortDescriptors: [NSSortDescriptor(keyPath: \Item.name, ascending: true)],         animation: .default) private var sectionedItems: SectionedFetchResults<String?, Item>          var body: some View {         NavigationView {             List {                 ForEach(sectionedItems) { section in                     Section(header: Text(Category.nameForId(section.id, context: viewContext)).font(.headline)) {                         ForEach(section) { item in                             NavigationLink(destination: ItemInputView(item: item, category: Category.get(identifier: item.category, context: viewContext))) {                                 Text(item.getName())                             }                         }                     }                 }             }                          .navigationTitle("Foo")             .sheet(isPresented: $isAddingItem) {                 ItemInputView(item: nil, category: Category.getDefault(context: viewContext))             }         }         .navigationViewStyle(.stack)     } }
1
0
1.3k
Jan ’22
Exporting from Roomplan when using
When using the RoomPlan UI (RoomCaptureView), one obtains the final result using  public func captureView(didPresent processedResult: CapturedRoom, error: Error?) which then gets exported via finalResults.export(to: url) What is the best way to do this if only using RoomCaptureSession? Should I just keep track if each CapturedRoom coming back in the delegate methods and use the final one?
1
0
1.6k
Jun ’22
Creating Entity Component System
I’m implementing my first Component Entity System and am having an issue. I have a requirement that some component properties be dynamic. I do not want to create a subclass that conforms to HasExampleComponent, so this was my approach. My issue is that even though the entity contains the property I can’t cast it to HasExampleComponent. When I create the entity I set the component like this: entity.components[ExampleComponent.self] = .init() I'd appreciate a template for a ECS with component properties that can be updated from the app. Thanks public struct ExampleComponent: Component {     public var value = 0 } public protocol HasExampleComponent: Entity { var value: Int } public class ExampleSystem: System {     private static let query = EntityQuery(where: .has(ExampleComponent.self))     public required init(scene: Scene) {}       public func update(context: SceneUpdateContext) {         context.scene.performQuery(Self.query).forEach { entity in // this won’t work because entity doesn’t conform to HasExampleComponent             entity.value += 1         }     } } extension Entity {     @available (iOS 15.0, *)     public var value: Int? {         get { components[RotatingComponent.self].value ?? 0}         set { components[RotatingComponent.self].value = newValue }     } }
0
0
785
Jun ’22
RoomCapture instruction view?
The RoomCaptureView seems to have a coaching controller analogous to the ARCoachingOverlayView. The content is available via public func captureSession(_ session: RoomCaptureSession, didProvide instruction: RoomCaptureSession.Instruction) Is the view that presents these instructions available if not using the RoomCaptureView?
0
0
1.3k
Jun ’22
Why is the pitch slider visible in SwiftUI tvOS map view?
Why is the pitch slider always visible in the SwiftUI tvOS map view? It doesn't even appear to be supported there, let alone the fact that I specify mapControlVisibility(.hidden). Am I missing something or is Apple? See attached screenshot. This really messes up my UI. Here is my code: import SwiftUI import MapKit struct ContentView: View { @State var position = MapCameraPosition.region(MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))) var body: some View { Map(position: $position) .mapControlVisibility(.hidden) .mapStyle(.standard(pointsOfInterest: .including(.airport))) } }
0
0
266
Mar ’25
Putting buttons over SwiftUI map view
Has anyone gotten custom buttons to work on top of tvOS Map()? I've tried many variations of FocusState focusSection .defaultFocus() and as soon as the map appears at startup the buttons never get focus again. They are on a ZStack over the map. I could post code but truthfully nothing works for me. I'm wondering if anyone has successfully put focusable buttons on top of the map view.
0
0
225
Mar ’25