Post

Replies

Boosts

Views

Activity

Reply to SwiftUI SceneKit populated but not displayed
OK, discovered the problem which lead to another. When porting my Delegate file from Swift to SwiftUI I had declared in a global variable file: var proton = SCNGeometry() ,which the var is. It is user selectable between: class Particle:SCNGeometry, SCNPhysicsContactDelegate {} and class WireFrameParticle:SCNGeometry, SCNPhysicsContactDelegate {} Experimenting, I found if I declare var proton = Particle() in the global var file, I get my desired SCNScene as SceneView. Likewise if var = WireFrameParticle(), I get the desired SCNScene as SceneView. When the user selects the "other" class from an options.toolbar where the var proton is reassigned, the program bombs, e.g., "Cannot assign WireFrameParticle to Particle". So, I modify my global var file to: var proton:SCNGeometry = Particle() The program no longer bombs but neither do I have the desired SCNScene in SceneView, again. There must be a way to declare/reassign the var proton, and have my scene too.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to App does not use my permissions to create dir
I have discovered an error that functioned in macOS but does not in iOS. Specifically, all the "atPath:" 's above are fed ".absoluteString" which must be ".path" in iOS. Correcting this eliminated the debugger statement: "Error Domain=NSCocoaErrorDomain Code=642 "You can’t save the file" Thanks to Leo Dabus Nov 23 '20 at 3:53 @ stackoverflow.com for pointing out the different results of each.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to SwiftUI SceneKit populated but not displayed
Not sure why it is working now, but here is what I did: First, I moved all scene initializing code into ContentView{},i.e., all node creation AND then included token nodes having drawn content (something to see). Secondly, it seems .temporalAntialiasingEnabled was/is incompatible with the simulated device of choice, so I removed it. Hope this helps.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Integrate Metal/ObjC Tutorial into SwiftUI
I modified the "Graphics and Games Engineer " code thus; struct MetalView: UIViewRepresentable {     func makeCoordinator() - Coordinator {         Coordinator(self)     }     func makeUIView(context: UIViewRepresentableContextMetalView) - MTKView {         let renderer = Renderer() //. Renderer() is from Apple's Tutorial "CPU-GPU-Synchronization.xcodeproj"         let mtkView = MTKView() //        mtkView.delegate = context.coordinator         mtkView.delegate = renderer     //  if this is the last edit, compiles but gives white screen         mtkView.preferredFramesPerSecond = 60         mtkView.enableSetNeedsDisplay = true // if let metalDevice = MTLCreateSystemDefaultDevice() { // mtkView.device = metalDevice // } if let metalDevice = renderer._device { mtkView.device = metalDevice } ... line 18 gives: "Value of type 'Renderer' has no member '_device' " and so I am stuck. I had programmed the first 128K Mac using C, when its native language was Pascal. However, I had never used ObjectiveC until now and the syntax foils me. If an ObjC @implementation is as a Swift class, then why isn't _device a member?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Integrate Metal/ObjC Tutorial into SwiftUI
Apple's Tutorial "CPU-GPU-Synchronization.xcodeproj" is readily available so I won't post any part of it. It is a stand-alone app that I want to launch from my SwiftUI app in some-or-any view. In "developer.apple.com/forums/thread/119112" a "Graphics and Games Engineer " kindly posted the code for creating the Coordinator, device, CommandQueue, etc. within SwiftUI code. What code/syntax is needed in either the objc tutorial code or the SwiftUI code to get the tutorial app to draw into the SwiftUI-created space? Or am I making this more complicated than it should be? I have tried creating a class in Swift with the Swift UIRepresentable as a var, then preface that class with "@objc" which should have made it available to the tutorial code, but it doesn't recognize it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to NSOpenPanel not closing after OK button
Claude31, if I understand you, I protocol my ViewController, of which runSavePanel() and OpenSavePanelDelegate are a part. OK, did that. Also replaced the two lines with the one. Now the modal window goes away but the app no longer saves files to the chosen location, nor anywhere. As if the sandbox nix'ed it. What & how do I catch any error in the delegate? The only sample code I found uses a custom error of my own choosing, not a system error.
Topic: UI Frameworks SubTopic: AppKit Tags:
Sep ’21
Reply to NSOpenPanel not closing after OK button
Claude31: the ViewController class is HUGE so, impractical to post. "Developer Documentation" in Xcode is spartan. Having said that, it now shows ".allowedFileTypes[]" as deprecated but has: "var allowedContentTypes: [UTType]" and "var allowsOtherFileTypes: Bool" available. In any case I'm OK with not specifying the fileType as I control them programmatically anyway. btw if I use "savePanel.delegate = self" , the debugger posts: "unrecognized selector sent to instance" but if I use: let delegate = OpenSavePanelDelegate() savePanel.delegate = delegate it posts no errors but I'm back to my original problem; modal staying open until all 184 files written. |-( I've triple-checked, runSavePanel() is only called once; when the JSONall() button is pushed. The modal must be waiting for some message-of-completion. I would have thought it receives the message when the OK button is hit or better yet, when the url is verified. Which all sounds like delegate action to me, but why is the delegate so lazy?
Topic: UI Frameworks SubTopic: AppKit Tags:
Sep ’21
Reply to NSOpenPanel not closing after OK button
All my code w.r.t. panel() and delegation is posted above. I set a delegate to the savePanel because I use the validate function. If the modal response is OK then it tries to save to the validated url. There must be some unpublished delegation. Normally, a user would save one file, and this happens quickly. I initiate the savePanel just to get the sandbox satisfied and then calculate and save much data in many files. It is as if the delegate is waiting for control to be given back to the user. I do use DispatchQueues, a few for each file generated so there is no "freeze-out" of the user. Even so, I would think the panel should close after the first file is saved.
Topic: UI Frameworks SubTopic: AppKit Tags:
Sep ’21
Reply to NSOpenPanel not closing after OK button
I am also confused by the NSOpenSavePanelDelegate functions. As a protocol I must declare a class that conforms. That class should already have those functions available which are they inherited by the instance variable. In practice, the class must re-declare those functions?!. It may be obvious but I have avoided delegation until now. High level languages are powerful but when details of what a command does are not robust, results can be unexpected and potentially unamendable.
Topic: UI Frameworks SubTopic: AppKit Tags:
Sep ’21
Reply to Missing Fundamental something
Thanks for the reply Claude31. **What do you get exactly ? Nothing ? some drawing, partly outside ?** Just a grey window. No indication of drawing anywhere. **add path.stroke() after shapeLayer.strikeColor = ...** When added I get the error: "Value of type 'CGMutablePath' has no member 'stroke'" You also mention in code: // ranges.append(0...0) // inexplicably FAILS! @ ordinateMinimum/ordinateMaximum if replaces "if N == 1" below Where does this fail ? ranges.append(0...0) does not fail where do you compute ordinateMinimum/ordinateMaximum ? When the following lines are executed, the result is ordinateMinimum = 0 AND ordinateMaximum = 0 which then results in ordinateScale = inf ordinateMinimum = CGFloat(ranges.min(by: {$0 != 0...0 && $1 != 0...0 && $0.lowerBound < $1.lowerBound})!.lowerBound) ordinateMaximum = CGFloat(ranges.max(by: {$0 != 0...0 && $1 != 0...0 && $0.upperBound < $1.upperBound})!.upperBound) ordinateScale = analysisView.frame.height/(ordinateMaximum - ordinateMinimum)
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’21
Reply to Missing Fundamental something
As for the second problem... Try this on your Playground: import UIKit let ranges = [ 1...4 ,0...0 ,0...1 ,3...5 ,0...0 ,2...4 ,3...7 ] let ordinateMinimum = CGFloat(ranges.min(by: {$0 != 0...0 && $1 != 0...0 && $0.lowerBound < $1.lowerBound})!.lowerBound) let ordinateMaximum = CGFloat(ranges.max(by: {$0 != 0...0 && $1 != 0...0 && $0.upperBound < $1.upperBound})!.upperBound) print("ordinateMinimum: \(ordinateMinimum)\nordinateMaximum: \(ordinateMaximum)") Now if you erase the first entry 1...4 so that 0...0 is the first entry, you will get a totally different and WRONG answer! Curious.
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’21