Posts

Post marked as solved
9 Replies
1.3k Views
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
Posted Last updated
.
Post marked as solved
2 Replies
169 Views
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.
Posted Last updated
.
Post not yet marked as solved
1 Replies
215 Views
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
Posted Last updated
.
Post marked as solved
2 Replies
323 Views
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.
Posted Last updated
.
Post marked as solved
5 Replies
782 Views
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
Posted Last updated
.
Post marked as solved
2 Replies
568 Views
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 } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
593 Views
MAGMA API runs on NVIDIA or AMD GPU's via CUDA. Are there plans to code Accelerate for Metal? Thanks
Posted Last updated
.
Post marked as solved
1 Replies
595 Views
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.
Posted Last updated
.
Post not yet marked as solved
6 Replies
1.1k Views
I use as many cpu's as I can get with DispatchQueue. How do I test the Mac for cpu count in my code?
Posted Last updated
.
Post marked as solved
5 Replies
695 Views
This is the second issue in my post "ProgressBar with DispatchQueue", delegation. I have used delegates with menu items but not program vars. In the previous post my ViewController has a progress bar but I would like the progress.DoubleValue var to be updated in a remote function, i.e., a function not declared within the ViewController class. (If I moved the function into the ViewController it would double in size.) How do I create and implement such a delegate? Please give example code. Thanks.
Posted Last updated
.
Post marked as solved
3 Replies
769 Views
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.
Posted Last updated
.
Post not yet marked as solved
5 Replies
913 Views
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?
Posted Last updated
.
Post not yet marked as solved
3 Replies
554 Views
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.
Posted Last updated
.
Post not yet marked as solved
0 Replies
575 Views
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.
Posted Last updated
.