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
}
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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.
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.
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.
there are other unresolved posts on this issue but maybe mine is solvable.
I copied the files I contributed from a working project to a new project using the finder (drag and drop). So I did not copy entitlements. Xcode automatically added the files to the project just fine. My app uses data on a removable drive, or used to, because I now get the error above. At one point I copied the product app to the desktop hoping to get the permissions alert window, but it never came. Oddly, in System Settings/Privacy & Security/Files & Folders my "new" app is listed with "Removable Volumes" slider = on.
The file permissions (unix-like) on that drive haven't changed between projects and allow everyone to read.
How can I fix this?
I didn't find a suggestion box on Swift's website so I'll post it here.
SwiftCharts are great but limited. I need more data on a single chart. Candlestick and OHLC type charts would be an excellent addition. Hopefully, influencers from Apple can make that happen.
Thanks.
running my Xcode app in Simulator: screenshots are sent to Library/Developer/CoreSimulator/Devices
followed by the cryptic code for the device ( given in /Library/Developer/CoreSimulator/Devices/device_set.plist ), a subdirectory then the PNG file. This is very inconvenient.
How to I set the desired directory?
I have developed an app using SceneKit since Swift came out. Now SwiftUI is out and uses structs rather than classes. SceneKit is a cascade of classes. As a newbie, I am concerned that my code might be obsolete through depreciations soon after publication and I'd rather get ahead of the issues now. So, is SceneKit long-term viable? My first attempts at converting my custom classes to structs seems impossible without Apple leading the way. If I understand correctly, I can make a struct whose only member is an instance of a class, but the benefits of the struct, e.g., minimal memory, processing time, etc., are lost.
Big Sur corrupted Disk Utility?
Just touching the File menu requires futile (endless) authorization.
Anyone else have this issue?
I've written an Switft/macOS App that creates directories deep within its own hierarchy. (no problem). Porting to SwiftUI means these directories and files should go(default) to ~/Documents. Since my Documents dir is (chmod -r 700) the ported app cannot write due to permissions. Which begs he question: what ID does the running app use?
I found:
https://developer.apple.com/forums/thread/82503?answerId=249036022#249036022
and it did change Xcode's :
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 502
but it still does not write as though it has my permissions.
Aside from changing my ~/Documents dir permissions, how do I make my App (build/run within Xcode) as me so it can write?
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.
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.
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?
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
I have modified Apple's Tutorial "CPU-GPU-Synchronization.xcodeproj" to suit my needs but cannot see how to launch it, e.g., as a sheet, from a Button inside a SwiftUI App.
I found this:
"developer.apple.com/forums/thread/119112"
which establishes the Coordinater wrapper, device and CommandQueue, etc., but how do I "replace?" those already established in ObjC code? For example, ObjC does not recognize SwiftUI struct's and I can't @objc preface a SwiftUI struct as I can a SwiftUI class(ref. the above thread).
Alternatively, is this the best venue to ask Apple to update/integrate their tutorials?
Thanks.