Post

Replies

Boosts

Views

Activity

Gesture's value.entity does not have previously set entity.name
Hi all, I'm trying to retrieve the name of an entity from the gesture that hits it, but it's not giving me the value I set when I created the entity. I create the entity like: class DrumPad: ObservableObject { static func create(for audioFileName: String) -> Entity? { do { let padEntity = try Entity.load(named: "Geometry/pad-without-handle", in: tableDrummerContentBundle) padEntity.name = "\(audioFileName)_pad" return padEntity } catch { print("Could not load pad \(audioFileName)") print(error.localizedDescription) return nil } } } Then I get it from the gesture: var body: some View { RealityView { content in for sampleName in audioSamples { guard let pad = DrumPad.create(for: sampleName) else { continue } content.add(pad) } } .gesture(SpatialTapGesture() .targetedToAnyEntity() .onEnded { value in print(value.entity.name) }) } } In the gesture handler, print(value.entity.name) gives me the name of the root transform of the entity, PadTransform, not the string I set "\(audioFileName)_pad" during instantiation. If I call print(padEntity.name) during instantiation, I get rock-kick-2_pad and the like. Any help would be much appreciated.
0
0
428
Feb ’24
iOS Requests Permission to Sign In when Signing/Logging Out
When using an ASWebAuthenticationSession to log in, with prefersEphemeralSession = false to enable SSO, the system presents an alert asking if the user wants to allow "SomeApp" to Sign In with "someauthprovider.xyz". The system presents exactly the same alert when you want to log out, and it is confusing for users. It's my understanding that the system does this because the alert really means "would you like to allow this app to let some page access Safari's shared cookie vault?" in lay terms, and is not distinguishing between create, read, update, or delete. It would be splendid if Apple changes this dialog depending on the operation. I would also like to know if there is any other way to fix this.
1
0
593
Apr ’24
Considering Alternatives to SwiftUI for a Complex App
I am working on an application that has some complex navigation needs, and I'm considering abandoning SwiftUI, at least in a few core areas of the app. I found SwiftUI intuitive and useful for simple things like: Using a state to toggle the appearance or disappearance of an element Using state to alter the look of UI elements Watching the values of built-in interfaces like TextField or Slider Controlling out-of-the-box UI elements like NavigationSplitView But now I've got a UI that depends on a data model that can change at any time, and from that data I'll display lists of objects, and objects in detail, and all of this will be displayed according to a NavigationPath that depends on the data model's internal structure. This means that, for instance, I may be in the detail view of element X after having traveled to it from the detail view of element Y which was tapped in a list of XYZ, which was the result of tapping into part of the detail view of element W. This whole path could be invalidated by an update to the data model when it's received from the network. Furthermore, any element could have it's details changed, or be deleted, and I'd want the UI to reflect that right away if possible. For the navigation work, I'm still optimistic that custom edits to a NavigationPath could be the way to go. However, for propagating data updates around my app, I know @State, @Bindable, etc are intended to handle this kind of thing, but when I'm try to send these bindings through the circuitous path of views I mentioned above, and I run into any unexpected hiccup, it feels like I'm at a disadvantage when debugging because I'm relying on opaque SwiftUI Magic to handle things under the hood in a way I don't really understand. I could put more effort into learning how this works, and potentially come up against some platform limitations, bugs, or other dead-ends, or I could just use Pub/Sub and a network of custom queues/pipes, and send updates around my app the old fashioned way, but using primitives whose functions are clear to me. I've been using SwiftUI for about a year and it still trips me up, and I have watched a few WWDC talks on the topic. I'd appreciate any advice on this front from the frequenters of this forum. Thanks for reading my post.
3
0
304
Sep ’24
Official documentation for Instruments?
Can somebody help me find the official documentation for instruments? Google brings you to this forum, then the link at the top of this forum for Instruments documentation brings you to the Xcode page, which links to these Apple developer docs, wherein a search returns nothing for "Instruments". Searching these Xcode docs for "Instruments" returns only this specific use case on analyzing HTTP traffic.
1
0
254
Sep ’24