Posts

Post not yet marked as solved
1 Replies
335 Views
I created a SwiftChart as below and I would like to have two YAxis, one for amount and the second for count. So, the amount YAxis is a different scale then the count YAxis. Does anybody have an example of this or shed some light on coding two different YAxis? Thanks ForEach(seriesArt) { series in ForEach(series.chartSeries.chartEntry) { BarMark( x: .value("Tier", $0.tier), y: .value("Price", $0.keyValue) ) } .foregroundStyle(by: .value("Count", series.chartCategory)) .position(by: .value("Price", series.chartCategory)) } } .frame(width: 400, height: 200) .chartXAxis { AxisMarks(position: .bottom, values: .automatic) { AxisValueLabel() .foregroundStyle(Color.white) } } .chartYAxis { AxisMarks(position: .leading, values: .automatic) { value in AxisGridLine(centered: true, stroke: StrokeStyle(lineWidth: 1)) AxisValueLabel() { if let intValue = value.as(Int.self) { Text("\(intValue)") .font(.system(size: 10)) .foregroundColor(.white) } } } .chartYAixs - for count sum by tier which needs to be a different scale from the amount YAxis } } }
Posted
by BigEagle.
Last updated
.
Post not yet marked as solved
2 Replies
2.1k Views
I understand by default SwiftData uses SQLite database but it can be configured to persist data in XML, binary and even in-memory databases. Does anybody know where SwiftData the SQLite database is located?
Posted
by BigEagle.
Last updated
.
Post marked as solved
5 Replies
1.4k Views
I don't see the structured editing popover when I command right click on an IOS SwiftUI project when I create a new project with just "Hello World" like I see in Xcode 13. Am I missing some thing or is this a bug? Thanks
Posted
by BigEagle.
Last updated
.
Post marked as solved
5 Replies
470 Views
I have the following test code: import SwiftUI struct ContentView: View { @State private var draggedImages: [UIImage?] = Array(repeating: nil, count: 5) @State private var savedToDisk = false var body: some View { VStack { HStack { ForEach(0..<5, id: \.self) { index in let image = draggedImages[index] ?? UIImage(systemName: "photo") Image(uiImage: image!) .resizable() .frame(width: 80, height: 80) .padding() .background(Color.blue) .foregroundColor(.white) .cornerRadius(10) .onDrag { return NSItemProvider(object: UIImage(systemName: "photo")!) } .onDrop(of: ["public.image"], isTargeted: nil) { providers, _ in providers.first?.loadDataRepresentation(forTypeIdentifier: "public.image") { data, error in if let data = data, let uiImage = UIImage(data: data) { draggedImages[index] = uiImage saveImageToDisk(image: uiImage, imageNumber: index) } } return true } } .alert(isPresented: $savedToDisk) { Alert(title: Text("Images Saved"), message: Text("The images have been saved to disk."), dismissButton: .default(Text("OK"))) } Spacer() } } .padding() } private func saveImageToDisk(image: UIImage, imageNumber: Int) { if let imageData = image.pngData() { do { let documentsDirectory = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) let imageUrl = documentsDirectory.appendingPathComponent("image_\(imageNumber).png") try imageData.write(to: imageUrl) savedToDisk = true } catch { print("Error saving image: \(error)") } } } } I can drag and drop as well as the dragged image is save on the second placeholder thru the fifth but not the first When I drag and drop to the first image another files app opens but when I close this the image is not saved. Any Ideas why the first image behaves differently to all the others? I test on Sonoma and Xcode 15 beta 7, I wil give it a try on Ventura and Xcode 14 later today to see if the same thing happens. Thanks
Posted
by BigEagle.
Last updated
.
Post not yet marked as solved
3 Replies
474 Views
I have the following test code import SwiftUI struct ContentView: View { @State private var field1 = "" @State private var field2 = "" @State private var field3 = "" var body: some View { VStack { Form { Section(header: Text("Input Fields")) { TextField("Field 1", text: $field1) TextField("Field 2", text: $field2) TextField("Field 3", text: $field3) } } List { ForEach(1..<6) { index in Text("Item \(index)") } } .listStyle(InsetListStyle()) } .navigationTitle("Form and List View") .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Dismiss") { // Handle dismiss action } .foregroundStyle(.red) // } ToolbarItem(placement: .primaryAction) { Button("Done") { // Handle done action } .foregroundStyle(.green) // } } } } I can't customize the color of the Buttons. Besides .foreground modifier I have tried ..foregroundColor(.red) and .foregroundColor(.green) to no avail. How can I customize the buttons in the toolbar for both macOS and IOS
Posted
by BigEagle.
Last updated
.
Post not yet marked as solved
1 Replies
790 Views
I am getting the following error on this line of code @Query(sort: \.id, order: .reverse) private var artList: [ArtInventory] Cannot infer key path type from context; consider explicitly specifying a root type So, I select fix and then the line of code then look like this @Query(sort: \<#Root#>.id, order: .reverse) private var artList: [ArtInventory] with this error Invalid component of Swift key path Some seems to have changed with the @Query macro in beta 5, which now needs a root type, but not sure how to proceed. Any ideas how to fix?
Posted
by BigEagle.
Last updated
.
Post not yet marked as solved
3 Replies
587 Views
I have a test project with a bar progress indicator create on Ventura with Xcode 14.3.1., It does not show the any animation until the @IBAction function completes. I want to show progress as it progresses not a just the end? Any ideas how to fix this? Below is my test project code.. // // ViewController.swift // ProgressTest // // Created by Bob on 6/5/23. // import Cocoa class ViewController: NSViewController { @IBOutlet weak var progressIndicator: NSProgressIndicator! // var progress: Double = 0.0 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } override var representedObject: Any? { didSet { // Update the view, if already loaded. } } @IBAction func progressStart(_ sender: Any) { // Start the progress animation progressIndicator.startAnimation(self) // Do some work here... // Do some work here... var progress: Double = 0.0 for _ in 0..<100 { // Update the progress value in a loop progress += 1.0 progressIndicator.doubleValue = progress // progress = Double(i) // progressIndicator.increment(by: 10) // progressIndicator.doubleValue = progress // Do some work here... } // Stop the progress animation progressIndicator.stopAnimation(self) } } thanks Bob
Posted
by BigEagle.
Last updated
.
Post not yet marked as solved
0 Replies
370 Views
The find and replace in project is not working for me in Xcode 14.2 on Ventura 13.2. When I enter the find text as well as the replace text the "Replace" and "Replace All" buttons remained grayed out. Is this a bug with Xcode or am I missing something? Please advise.
Posted
by BigEagle.
Last updated
.
Post not yet marked as solved
4 Replies
882 Views
I want to put some code to be run when my app terminates but the following:        func applicationWillTerminate(_ aNotification: Notification) {             // Insert code here to tear down your application             print("Termination Code")         } in the AppDelegate class is not called, any ideas how to fix this issue. I saw this posts https://developer.apple.com/forums/thread/126418 but I do not have an info.plist. I think the info.plist is not longer needed. The following doc does not have much to say about this?? https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428522-applicationwillterminate
Posted
by BigEagle.
Last updated
.
Post not yet marked as solved
3 Replies
2.1k Views
For a macOS app using Xcode 14.1. I have a bar chart with two bars for each interval. See screen chart below. I want to change the "Invoice" and Payments" text I can't seem to find a modifier for the Legend text. How do you change the text color for SwiftUI Chart's legend text?
Posted
by BigEagle.
Last updated
.
Post marked as solved
4 Replies
994 Views
I have a macOS tableview I have a textfield as a column along with an IBAction code to capture the data from this field. I wanted to add continuous spell check for this column . So, I decided to change the column from a TextField to a ScrollView to take advantage of the continuous spell check. Using Xcode 14 I changed the Cell to a custom Cell. The custom cell has a scrollview object as the object because I want to take advantage of the built in continuous spell checking instead of using a textfield. All is well with this implementation until I tried to add a IBAction code for when I enter text in the scrollview/textView field. There does not seem to be a way to capture the text? Am I trying to do something that can't be done or is there a way to add continuous spell check to a textField?
Posted
by BigEagle.
Last updated
.
Post marked as solved
2 Replies
535 Views
I have the following code: class ChartSeriesRow: ObservableObject {     var id = UUID()     var chartCategory: String     struct ChartSeriesData {         var chartEntry: [ChartData]     }     var chartSeries : ChartSeriesData     struct ChartData: Codable, Identifiable, Hashable {         var id = UUID()         let chartMonth: String         let chartSales: String     }     init() {         chartCategory = ""         chartSeries = ChartSeriesData(chartEntry: [ChartData(chartMonth: "01", chartSales: "10.0") ] )     } } How do I populate ChartSeriesData? I thought I could just add the following: However coding this way there is no append method. extension ChartSeriesRow {     func addRow(chartRow: ChartSeriesData){          ChartSeriesRow.ChartSeriesData.chartEntry.append(contentsOf: chartRow)     } }
Posted
by BigEagle.
Last updated
.
Post marked as solved
3 Replies
583 Views
From the class below how do I initialize chartEntry for the structure array? As it is below chartEntry is outside scope of init? class ChartSeriesRow: ObservableObject {     var id = UUID()     var chartCategory: String     struct chartSeriesData{         var chartEntry: [ChartData]     }     struct ChartData: Codable, Identifiable, Hashable {         var id = UUID()         let chartMonth: String         let chartSales: String     }     init() {         chartCategory = ""         chartEntry = chartSeriesData: [ChartData.chartMonth: "01",  ChartData.chartSales: "10.0"]     }      }
Posted
by BigEagle.
Last updated
.
Post not yet marked as solved
0 Replies
919 Views
Environment : macOS Ventura Xcode beta 14.1: I have the following chart I was using to learn about SwifUI Charts: I wanted to have different scales on the leading and trailing yaxis as well as have the first 3 bars to use leading scale and the last two bars use the trailing scale. Can this be done? If so, how? Thanks
Posted
by BigEagle.
Last updated
.