Post

Replies

Boosts

Views

Activity

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
Reply to Missing Fundamental something
I understand about multiple issues. I'll try to keep them separate in the future. Thanks. You looked into this pretty deeply, and it reminds me of a mathematicians proof. They can be more litigious than lawyers, and necessarily so. I didn't submit my case well. I just find it curious that if you run the min/max code on ranges =[ 1...4 ,0...0 ,1...6 ,3...5 ,0...0 ,2...4 ,3...7 ] you get a min=1 and max=7, and that is what I expect when looking at the data. But now swap the first and second entries so that: ranges = [ 0...0 ,1...4 ,1...6 ,3...5 ,0...0 ,2...4 ,3...7 ] the result is min=0 and max=0 It is the same data, just rearranged. The results are dramatically different. The reason for it still eludes me. Filtering is a good way to go. Thanks.
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’21
Reply to Delegation in Swift
Sorry, robnotyou, I should have posted the link: https://developer.apple.com/forums/thread/694710 to my previous post where Claude31 contributed heavily. In it Clause31 creates example program with a progressBar within the VC class and thus progressBar.doubleValue is recognized. But in my actual app "remote func" is not in the VC class nor any other class but is just in a separate file, alone, by itself at 800 lines of code. I don't want to fatten my already bloated VC file. The remote function runs many iterations thus the need for a progress indicator. A delegate (if I understand correctly) will update the progressBar.doubleValue even though the delegate itself is changed in the remote func. I hope that is clearer. I may be asking for something that can't be done. I have dabbled in SwiftUI and what I am asking for in Swift is something analogous to an EnvironmentVariable update scheme, i.e., when the other file changes a value it is reflected in the VC. wherever it is needed.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to FYI: Playing a movie using AVPlayer in Big Sur
Belated follow-up to my own question. The following code works, and is not much different than that already posted. So my problem must have been in the storyboard. import AVKit // macOS & iOS class ViewController_myProduction: NSViewController { @IBOutlet var myMOV: AVPlayerView! override func viewDidLoad() { super.viewDidLoad() let playerView = AVPlayerView() playerView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(playerView) if #available(macOS 11.0, *) { playerView.leadingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.leadingAnchor ).isActive = true playerView.trailingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true playerView.topAnchor.constraint (equalTo: view.safeAreaLayoutGuide.topAnchor ).isActive = true playerView.bottomAnchor.constraint (equalTo: view.safeAreaLayoutGuide.bottomAnchor ).isActive = true } else { // Fallback on earlier versions } playerView.controlsStyle = .floating playerView.showsFrameSteppingButtons = true playerView.showsFullScreenToggleButton = true guard let path = Bundle.main.url(forResource: "myProduction", withExtension: "mov") else { return } let player = AVPlayer(url: path) playerView.player = player playerView.player?.play() } } note to self: code-block + Edit:"Paste and Match Style"
Jan ’22
Reply to format printed SIMD3's
I am working a new tac. I use my existing Double extension I call EE() on each of the elements of a simd_double3, which obviously has three double elements. I've abandoned SIMD3 with its scalars. so: extension simd_double3 { func EE_simd_double3(_ sigDig: Int?,_ toSize: Int?,_ padChar: String?) -> String { return "(\((self.x).EE(sigDig,toSize,padChar)), \((self.y).EE(sigDig,toSize,padChar)), \((self.z).EE(sigDig,toSize,padChar)))" } } extension Double { func EE(_ sigDig: Int?,_ toSize: Int?,_ padChar: String?) -> String { let formatter = NumberFormatter() formatter.numberStyle = .scientific formatter.positivePrefix = "+" formatter.maximumIntegerDigits = 1 formatter.usesSignificantDigits = true formatter.minimumSignificantDigits = sigDig ?? 4 formatter.maximumSignificantDigits = sigDig ?? 5 return formatter.string(from: self as NSNumber)!.pad(padWithString: padChar ?? " ", toSize: toSize ?? 16, prefix: false) //.padding(toLength: padTo ?? 26, withPad: padChar ?? " ", startingAt: stringNum.count) } } My remaining problems are how to include the plus sign after the E in scientific nation, e.g., -4.516611095E1 -> -4.516611095E+1 and to specify the number of digits after E, e.g., -4.516611095E1 -> -4.516611095E+01
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to format printed SIMD3's
extension String { func pad(padWithString: String, toSize: Int, prefix: Bool) -> String { var padChar = " " if toSize >= self.count { for _ in 0..<(toSize - self.count) { padChar = padWithString + padChar } } if prefix { return padChar + self } else { return self + padChar } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22