Post

Replies

Boosts

Views

Activity

Reply to Context menu under touch
I managed to get the edit menu working with the following code. class MyARView: ARView, UIEditMenuInteractionDelegate { private var editMenuInteraction: UIEditMenuInteraction? = nil required init(frame frameRect: CGRect) { super.init(frame: frameRect) setupEditMenu() } required dynamic init?(coder decoder: NSCoder) { super.init(coder: decoder) setupEditMenu() } override init(frame frameRect: CGRect, cameraMode: ARView.CameraMode, automaticallyConfigureSession: Bool) { super.init(frame: frameRect, cameraMode: cameraMode, automaticallyConfigureSession: automaticallyConfigureSession) setupEditMenu() } func isValidHitTest(at location: CGPoint) -> Bool { // TODO: Implement... // return true } func setupEditMenu() { print("Hello, world!") editMenuInteraction = UIEditMenuInteraction(delegate: self) if let editMenuInteraction { self.addInteraction(editMenuInteraction) } let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(_:))) self.addGestureRecognizer(longPressGestureRecognizer) } func editMenuInteraction(_ interaction: UIEditMenuInteraction, menuFor configuration: UIEditMenuConfiguration, suggestedActions: [UIMenuElement]) -> UIMenu? { UIMenu( title: "", options: .displayInline, children: [ UIAction(title: "Menu Option") { _ in print("Do the thing") } ] ) } @objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) { guard gestureRecognizer.state == .began else { return } let location = gestureRecognizer.location(in: self) guard isValidHitTest(at: location) else { return } let configuration = UIEditMenuConfiguration(identifier: "MyARView", sourcePoint: location) editMenuInteraction?.presentEditMenu(with: configuration) } }
Oct ’23
Reply to Custom struct Codable for SwiftData
I enabled the arguments/environment-variables to debug what the sqllite database was doing behind the scenes, and now I'm even more confused. TraceSQL(0x127e12970): INSERT INTO ZVARIANTMODEL( Z_PK, Z_ENT, Z_OPT, ZPROJECT, ZTHUMBNAIL, Z2VARIANTS, ZASSIGNMENTS, ZELEMENTGROUPS, ZGROUPEDELEMENTS, ZID, ZMODIFIEDON, ZNAME, ZSWATCHES ) VALUES( 1, 4, 1, NULL, NULL, 1, x'7b7d', NULL, NULL, x'31ddf4ce24b8463e9ede5bfe4457e19e', 718570686.400954, 'Super Long', x'62706c697374303...00000000000005f' ) If I'm reading this correctly, it appears to be storing ZELEMENTGROUPS and ZGROUPEDELEMENTS which are the internal stored values on the Group type. I would have assumed it would instead just use whatever implementation I have for Codable? It is storing nil for both of these types. This seems very odd, and not what I would expect at all.
Oct ’23