Post

Replies

Boosts

Views

Activity

SceneView camera viewpoint restoration
SceneKit SCNScene MacOS 15.1 Xcode 16.0 SceneView(scene: , options:[autoenablesDefaultLighting, allowsCameraContol] there is: .rootNode.cameraNode .rootNode.camera .rootNode.nestedChildNodes each with its own animation when the object is animated and dragged by mouse to change the view point, I can't return the view to the previous view. I have reinstated a clone of the original cameraNode, positions of all childNodes, removed and re-activated all animations... in vain. I have also cloned, removed and replaced .rootNode.camera, in vain. The documentation states the camera is "attached" to an SCNNode but does not say how. I make no declaration to associate .rootNode.cameraNode to .rootNode.camera yet if either is absent there is no scene to view. What am I missing? Thanks
1
0
160
1w
simple? filename sort
given [URL.lastPathComponent] how do I sort as Finder sorts in macOS? Example: urlPaths = contentsOfDirectory(at: ... e.g., ["1H", "10Ne", "11Na"] urlPaths.sort(by: { $0 < $1 } //Apple Swift version 5.9 print(urlPaths) // 10Ne 11Na 1H whereas Finder filename sort gives // 1H 10Ne 11 Na and is beautiful. I have always taken this sort for granted and am now buggered to duplicate it.
2
0
418
Feb ’24
macOS load file progress indication
My app generates many files as large as 12 GB (limited by memory) and I use Picker() to select which to reload with FileManager(). The larger files can take three minutes to load (M2 Mini Pro) and it would be nice to have progress indication like Apple's App Store downloads with the mini spinner, file size and bytes loaded. From what I've read in "Developer Documentation", I must use a URLdelegate instance I have created, not the shared delegate, when effecting a URL download. "Downloading files in the Background" shows iOS code, not macOS, and it also uses a "shared" delegate. A post, here, dated years ago said what I seek is not possible and I have not found recent sample code to show otherwise. Can anyone shed light on this? Thanks
1
0
435
Feb ’24
JSONEncoder has changed
Prior to Sonoma 14.0 and Xcode 15.0.1 my custom class was encoded in a consistent pattern that I exploited to append the file many thousands of times. Now, the encodings are of a seemingly random pattern that cannot be exploited to append. This may be a result of efforts to make the encoding more efficient or virtually any other reason. My questions are: how do I revert to the previous JSONEncoder while using current OS & Xcode versions?, i.e, what files and in what locations do I restore? is it likely to be sustainable if I did so? It has been previously noted that atomic files are not "append able" which is why I used JSON in the first place. Any info or suggestion is appreciated. Thank you.
2
1
608
Nov ’23
memory race on deep looper
Below is some simple code that does nothing, saves nothing. Yet the memory usage keeps rising. Am I missing something or is this a bug? The code requires 6 core CPU minimum. ContentView.swift import SwiftUI import Combine struct ContentView: View { @EnvironmentObject var loopClass:LoopClass var body: some View { ProgressView(value: Float(loopClass.loop_count), total: Float(loopClass.max_loops) ).progressViewStyle(.circular).padding() Button("Run looper", action: { loopClass.loopFunc() } ) } } LoopClass.swift import Combine class LoopClass: ObservableObject { @Published var loop_count = 0 @Published var max_loops = 0 func loopFunc () { let loopSet = [ 1, 3, 5, 7, 11, 13 ] max_loops = Int(pow(Double(loopSet.count), 13.0)) print("max_loops = \(max_loops)") for loop13 in loopSet { DispatchQueue.global().async { for loop12 in loopSet { for loop11 in loopSet { for loop10 in loopSet { for loop9 in loopSet { for loop8 in loopSet { for loop17 in loopSet { for loop16 in loopSet { for loop5 in loopSet { for loop4 in loopSet { for loop3 in loopSet { for loop2 in loopSet { for loop1 in loopSet { DispatchQueue.main.async{ self.loop_count += 1 } } }}}}}}}}}}} } // DQ } // for loop13 } }
2
0
819
Jul ’23
12 core M2 mini only using 4 cores, Intel Mac mini used 6
Developing a program that needs maximum cores. My previous Intel Mac mini used all 6 cores, according to Activity Monitor. It showed 600% cpu usage. I assumed the M2 would use twelve, but only shows 400% cpu usage in Activity Monitor, ergo, two less! I don't recall setting a core usage parameter in Xcode. Any ideas? Ventura 13.3 and Xcode 14.3 up to date as of this post.
2
0
785
May ’23
Using LAPACK in macOS 13.3
My app complied when “Minimum Deployments” was 12.x but with 13.3 I get the alert: " 'dsyev_' was deprecated in macOS 13.3: The CLAPACK interface is deprecated. Please compile with -DACCELERATE_NEW_LAPACK to access the new lapack headers." Where do I enter this compiler flag? I am using XCode 14.3 Ventura 13.3.1 on an Intel macMini Build Phases:Link Binary With Libraries (3 items) libf77lapack.tbd libclapack.tbd liblapack.tbd each of which is provided by Apple. I have rooted around in “Build Settings”, “ Build Phases”, and “Build Rules” but can’t see where to put the compiler flag. Thanks
5
1
1.5k
May ’23
SecureCoding roadblock?
Attached is an entire project (4 files) that mirrors my actual project including the failure to save to file. Am I: missing some syntax in this code? failing to config a defaults file? not set the necessary parameters in " "Build Settings" or "Build Rules etc.? I was writing to JSON files, but now that I must append to files directly, and JSON doesn't do that easily, I am trying to write using native macOS tools. WELL, IT SEEMS I CAN'T SEND YOU THE CODE, TOO MANY CHARS. I CAN'T ATTACH ANY FILE EITHER. WHY OFFER IT IF IT IS NOT ALLOWED? ANYWAY, CAN YOU GLEAN ANYTHING FROM THIS... Thanks. My debugger area: 2022-05-28 12:03:11.827372-0500 exampleClassInClassSecureCoding[1508:29981] Metal API Validation Enabled 2022-05-28 12:03:11.940123-0500 exampleClassInClassSecureCoding[1508:29981] *** NSForwarding: warning: object 0x600003cf7090 of class 'exampleClassInClassSecureCoding.classOne' does not implement methodSignatureForSelector: -- trouble ahead Unrecognized selector -[exampleClassInClassSecureCoding.classOne replacementObjectForKeyedArchiver:] 2022-05-28 12:03:11.940416-0500 exampleClassInClassSecureCoding[1508:29981] Unrecognized selector -[exampleClassInClassSecureCoding.classOne replacementObjectForKeyedArchiver:] Unrecognized selector -[exampleClassInClassSecureCoding.classOne replacementObjectForKeyedArchiver:] Performing @selector(didPressButton:) from sender _TtC7SwiftUIP33_9FEBA96B0BC70E1682E82D239F242E7319SwiftUIAppKitButton 0x7ff08ab06480
9
0
1.8k
May ’22
Is Core Data the right tool?
My app generates piecemeal near terabyte data distributed over one hundred files. Due to RAM and internal HD limitations I must store to an external HD in piecemeal fashion. That is to say, append fresh records directly to an existing file without reading-in the whole file, appending, and writing it out again. Ultimately (when data generation ceases) I will check each file to ensure uniqueness of member data structures. Is Core Data the tool I should use? If not, how do I append directly to disk-files without first reading it in?
5
0
1.2k
May ’22
EnvironmentObject as progressValue in ProgressView()
The model increments through a range of dates converted to Double and scaled, ranging from 0 to 1.0 I wish to show a determinate progress bar. As I understand it, the ProgressView() must be declared in the ContentView and its progress var must be declared as a @State var The ContentView declares the model vars as @EnvironmentObjects If I declare: @State private var = model.progressValue I get the error:"Cannot use instance member 'model' within property initializer; property initializers run before 'self' is available" btw the model class declares: @Published var progressValue : Double The model func (to increment through dates) is launched by a button in the ContentView. idk how to get the incremented progressValue from the model to the ContentView State var.
3
0
1k
Feb ’22
format printed SIMD3's
I print a lot of SIMD3 vectors to the debugger area in Xcode. Some vector-elements have prefixed signs and some values are longer than others. I would like the printed vectors to align as they did in my old days of Fortran. The SIMD3 members are scalars which can't be cast as Double ( I know how to format output for Double) or even as NSNumber. Something akin to a NumberFormatter for vectors would be the objective, but I don't see how to do it. Scalars are wierd and (helpful) documentation sparse.
5
0
698
Jan ’22
Warning about truncatingRemainder
it may not deliver what you expect. For example: if you are using NASA/JPL/Standish equations of heliocentric planetary motion, it requires: "3. Modulus the mean anomaly (M) so that -180deg<=M<=+180deg and then obtain the eccentric anomaly, E, from the solution of Kepler's equation..." If you attempt to use the Swift "Modulo operator, %" you'll get the Xcode directive to use truncatingRemainder instead. Which IS better than % because of this note in "The Swift Programming Language (Swift 5.3)": "“NOTE The remainder operator (%) is also known as a modulo operator in other languages. However, its behavior in Swift for negative numbers means that, strictly speaking, it’s a remainder rather than a modulo operation.” Excerpt From The Swift Programming Language (Swift 5.3) Apple Inc. https://books.apple.com/us/book/the-swift-programming-language-swift-5-5/id881256329 This material may be protected by copyright. But you should try truncatingRemainder in your playground! Let: 0deg = 12 O'clock, 180/-180deg = 6 O'clock, -90deg = 9 O'clock and +90deg = 3 O'clock Now run this on your playground: let M = -181.25 var M180 = M while M180 > 180.0 { M180 -= 360.0 } while M180 < -180.0 { M180 += 360.0 } print("M = \(M)\t\tM180 = \(M180)\t\tM.truncatingRemainder(dividingBy: 180.0) = \(M.truncatingRemainder(dividingBy: 180.0))\t\tM.truncatingRemainder(dividingBy: 360.0) = \(M.truncatingRemainder(dividingBy: 360.0))") and you'll get this result: M = -181.25        M180 = 178.75 M.truncatingRemainder(dividingBy: 180.0) = -1.25 M.truncatingRemainder(dividingBy: 360.0) = -181.25 Thus, truncatingRemainder(dividingBy: 180.0) puts your planet 180deg away from where it should be, while M180 keeps the planets moving without quantum leaps.
0
0
682
Jan ’22