Post

Replies

Boosts

Views

Activity

SwiftData Tables disappearing while test my app!
I begin testing my IOS swiftdats Xcode 15 swift 5 on Sonoma and I am able to create my siwftdata tables as well as add records to several of the tables, Then as I proceeded with my te tables disappear and I get this error in the Xcode debug console: error: Error: Persistent History (6) has to be truncated due to the following entities being removed: ( AppSettings, Invoice, Clientele, Pay, InvoiceItem, TrackingArt ) This app used to work fine and as I was making changes it started behaving in this manner. Beside the code I will supply the entire debug console with the attached file debugConsole.txt Here is how I have the swift data containers setup. import SwiftData import TipKit import CloudKit @main struct ArtManagerApp: App { @StateObject private var copyInvoiceDetails = CopyInvoiceDetails() @StateObject private var copyPaymentDetails = CopyPaymentDetails() @StateObject private var artTypeSettings = ArtTypeSettings() @StateObject private var tipManager = TipManager() // @Query(sort: \ArtPiece.artPieceID, order: .forward) private var artPieces: [ArtPiece] // @Query(sort: \AppSettings.setID, order: .reverse) private var settingsList: [AppSettings] var sharedModelContainer: ModelContainer = { let schema = Schema([ ArtPiece.self, Clientele.self, TrackingArt.self, Invoice.self, InvoiceItem.self, AppSettings.self, Pay.self ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } }() var body: some Scene { WindowGroup { ContentView() .navigationTitle("🎨 Art Manager") .environmentObject(artTypeSettings) .environmentObject(copyInvoiceDetails) .environmentObject(copyPaymentDetails) .environmentObject(tipManager) // Pass it to the ContentView .modelContainer(sharedModelContainer) } } } class TipManager: ObservableObject { @Published var tips: [ArtManagerTip] = [] init() { loadTips() } func loadTips() { tips = [ArtManagerTips.search_tip, ArtManagerTips.delete_tip, ArtManagerTips.extendedSearch_tip, ArtManagerTips.searchPayments_tip, ArtManagerTips.searchArt_tip, ArtManagerTips.librarySearch_tip, ArtManagerTips.artMaintenanceSearch_tip] } } class CopyPaymentDetails: ObservableObject { @Published var payNumber: Int32 = 0 @Published var payType: String = "" @Published var payPatronID: Int32 = 0 @Published var payPatronName: String = "" @Published var payPatronAddress: String = "" @Published var payPaymentAmount: Double = 0.0 @Published var payDatePayed: Date = Date() } class CopyInvoiceDetails: ObservableObject { @Published var invoiceNumber: Int32 = 0 @Published var invoicePatronName: String = "" @Published var invoicePatronPO: String = "" @Published var invoiceDateCreated: Date = Date() @Published var artPieceIDSaved: [Int32] = [] }
7
0
1.4k
Aug ’24
NSPrintInfo design report
I am developing an macOS Xcode 12 app that requires printing. I have a basic understanding how to implement printing, I understand that I need to create a subclass of NSview to get going. However, I was wondering how to go about designing the report? Is this done with interface builder like designing a window layout or is all done with code, ie supplying position (x,y), headings, font, graphics, font size.. etc. How is this done? Also, does anybody have any tutorials on this? I have one example but it is very minimal print out, basically it prints a tableview with two columns. I got this from Coca Programming chapter 27, Big Nerd Ranch.
5
0
1k
May ’21
How to call function in NSViewController?
class CustViewController: NSViewController { @IBOutlet weak var tableView: NSTableView! @IBOutlet weak var statusLabel: NSTextField! fileprivate var selectedOptionFromMenu = "" @objc var contacts:[Person] = [] @objc var backUpContacts:[Person] = [] @IBAction func printCustomers(_ sender: Any?) { I would like to call the printCustomers function in the CustViewController from another class (NSWindowController). How is this coded in the NSWindowController class? I tried the following: let printAction = CustViewController.printCustomers(<#T##self: CustViewController##CustViewController#> ) but don't know how to code argument in this and this may be not be the way to do this?
Topic: UI Frameworks SubTopic: AppKit Tags:
5
0
738
Aug ’22
Why does the first image behave differently ?
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
5
0
1k
Sep ’23
Xcode 13.2 and Github - No Packages listed
I connected Github to Xcode 13.2 (Monterey macOS) successfully, however I do not see any packages available when I select Github as the source. I did download Xcode 13.2 from the developers website and it did fix some problems I was having with Xcode from the App Store but did make any difference to the issue above. Anybody else have this issue with Xcode 13.2?
4
0
1.2k
Mar ’22
NSPredicate format for date comparison
I have the following code to search a tableView. The contains format works fine for string arguments however can't seem to find the correct format to work with date arguments.   @objc func invoiceSearch(sender:NSSearchField) {     //    print ("\(#function): \(sender.stringValue)")             let searchString = sender.stringValue             var predicate:NSPredicate = NSPredicate()             if searchString.isEmpty {                 invoices = self.backUpInvoices             }             else{       // search field contains data                 if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "All" {                     predicate = NSPredicate(format: "invoiceNumber contains %@ OR invoiceCustName contains %@ OR invoiceStatus contains %@ OR invoiceDateCreated >= %@",searchString,searchString,searchString,searchString)                 }                 else if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "invoice Number" {                     predicate = NSPredicate(format: "invoiceNumber contains %@",searchString)                 }                 else if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "invoice Customer"{                     predicate = NSPredicate(format: "invoiceCustName contains %@",searchString)                 }                 else if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "invoice Status"{                     predicate = NSPredicate(format: "invoiceStatus contains %@",searchString)                 }                 else if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "Invoice Date"{                       predicate = NSPredicate(format: "invoiceDateCreated >= %@", searchString as CVarArg)                 }                 invoices = (self.backUpInvoices as NSArray).filtered(using: predicate) as! [Invoice]             }             invoiceCount = "Found \(items.count ) Invoices"             invoiceStatusLabel.stringValue = invoiceCount             self.tableView.reloadData()     } InvoiceDateCreated is defined by the following within a NSObject class: @objc   var invoiceDateCreated: Date? = Date() The error I get when trying to search on date is 2022-09-26 09:14:36.638553-0500 CashToMe[9107:6838576] [General] -[NSTaggedPointerString objCType]: unrecognized selector sent to instance I have read through the following documentation Apple Doc for NSPredicate How can I fix this. Also, if there is a better/newer way to code this I am open to changing the code. Thanks
4
0
2k
Sep ’22
How to add an IBAction to a macOS tableView Cell
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?
4
0
1.4k
Nov ’22
macOS Xcode 14.2 app applicationwillterminate function is not called
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
4
0
1.5k
Jan ’23
Populate one column based on values of other column in a NSTableView
How do you populate one column based on values of other column for a macOS app using Xcode 12 in a tableView? The value of the first column comes from a comboBox which I get control by using the following code connected to the comboBox: @IBAction func comboAction(_ sender: NSComboBox) {         print("Combo selected", sender.selectedTag(), sender.stringValue, sender.indexOfSelectedItem, sender.identifier as Any)         } Then base on the value of the comboBox column within the comboAction function I want to populate column 2. Can this be done? If so, how
3
0
819
Mar ’21
How to Initialize a structure with in a class?
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"]     }      }
3
0
887
Nov ’22
Progress Indicator not working as expected
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
3
0
1.4k
Jun ’23
How to customize buttons in a SwiftUI view toolbar
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
3
0
1.1k
Aug ’23
SwiftData Tables disappearing while test my app!
I begin testing my IOS swiftdats Xcode 15 swift 5 on Sonoma and I am able to create my siwftdata tables as well as add records to several of the tables, Then as I proceeded with my te tables disappear and I get this error in the Xcode debug console: error: Error: Persistent History (6) has to be truncated due to the following entities being removed: ( AppSettings, Invoice, Clientele, Pay, InvoiceItem, TrackingArt ) This app used to work fine and as I was making changes it started behaving in this manner. Beside the code I will supply the entire debug console with the attached file debugConsole.txt Here is how I have the swift data containers setup. import SwiftData import TipKit import CloudKit @main struct ArtManagerApp: App { @StateObject private var copyInvoiceDetails = CopyInvoiceDetails() @StateObject private var copyPaymentDetails = CopyPaymentDetails() @StateObject private var artTypeSettings = ArtTypeSettings() @StateObject private var tipManager = TipManager() // @Query(sort: \ArtPiece.artPieceID, order: .forward) private var artPieces: [ArtPiece] // @Query(sort: \AppSettings.setID, order: .reverse) private var settingsList: [AppSettings] var sharedModelContainer: ModelContainer = { let schema = Schema([ ArtPiece.self, Clientele.self, TrackingArt.self, Invoice.self, InvoiceItem.self, AppSettings.self, Pay.self ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } }() var body: some Scene { WindowGroup { ContentView() .navigationTitle("🎨 Art Manager") .environmentObject(artTypeSettings) .environmentObject(copyInvoiceDetails) .environmentObject(copyPaymentDetails) .environmentObject(tipManager) // Pass it to the ContentView .modelContainer(sharedModelContainer) } } } class TipManager: ObservableObject { @Published var tips: [ArtManagerTip] = [] init() { loadTips() } func loadTips() { tips = [ArtManagerTips.search_tip, ArtManagerTips.delete_tip, ArtManagerTips.extendedSearch_tip, ArtManagerTips.searchPayments_tip, ArtManagerTips.searchArt_tip, ArtManagerTips.librarySearch_tip, ArtManagerTips.artMaintenanceSearch_tip] } } class CopyPaymentDetails: ObservableObject { @Published var payNumber: Int32 = 0 @Published var payType: String = "" @Published var payPatronID: Int32 = 0 @Published var payPatronName: String = "" @Published var payPatronAddress: String = "" @Published var payPaymentAmount: Double = 0.0 @Published var payDatePayed: Date = Date() } class CopyInvoiceDetails: ObservableObject { @Published var invoiceNumber: Int32 = 0 @Published var invoicePatronName: String = "" @Published var invoicePatronPO: String = "" @Published var invoiceDateCreated: Date = Date() @Published var artPieceIDSaved: [Int32] = [] }
Replies
7
Boosts
0
Views
1.4k
Activity
Aug ’24
structured editing popover with Xcode 14.1 beta 3
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
Replies
6
Boosts
0
Views
2.1k
Activity
Sep ’23
NSPrintInfo design report
I am developing an macOS Xcode 12 app that requires printing. I have a basic understanding how to implement printing, I understand that I need to create a subclass of NSview to get going. However, I was wondering how to go about designing the report? Is this done with interface builder like designing a window layout or is all done with code, ie supplying position (x,y), headings, font, graphics, font size.. etc. How is this done? Also, does anybody have any tutorials on this? I have one example but it is very minimal print out, basically it prints a tableview with two columns. I got this from Coca Programming chapter 27, Big Nerd Ranch.
Replies
5
Boosts
0
Views
1k
Activity
May ’21
How to call function in NSViewController?
class CustViewController: NSViewController { @IBOutlet weak var tableView: NSTableView! @IBOutlet weak var statusLabel: NSTextField! fileprivate var selectedOptionFromMenu = "" @objc var contacts:[Person] = [] @objc var backUpContacts:[Person] = [] @IBAction func printCustomers(_ sender: Any?) { I would like to call the printCustomers function in the CustViewController from another class (NSWindowController). How is this coded in the NSWindowController class? I tried the following: let printAction = CustViewController.printCustomers(<#T##self: CustViewController##CustViewController#> ) but don't know how to code argument in this and this may be not be the way to do this?
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
5
Boosts
0
Views
738
Activity
Aug ’22
Why does the first image behave differently ?
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
Replies
5
Boosts
0
Views
1k
Activity
Sep ’23
Xcode 13.2 and Github - No Packages listed
I connected Github to Xcode 13.2 (Monterey macOS) successfully, however I do not see any packages available when I select Github as the source. I did download Xcode 13.2 from the developers website and it did fix some problems I was having with Xcode from the App Store but did make any difference to the issue above. Anybody else have this issue with Xcode 13.2?
Replies
4
Boosts
0
Views
1.2k
Activity
Mar ’22
NSPredicate format for date comparison
I have the following code to search a tableView. The contains format works fine for string arguments however can't seem to find the correct format to work with date arguments.   @objc func invoiceSearch(sender:NSSearchField) {     //    print ("\(#function): \(sender.stringValue)")             let searchString = sender.stringValue             var predicate:NSPredicate = NSPredicate()             if searchString.isEmpty {                 invoices = self.backUpInvoices             }             else{       // search field contains data                 if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "All" {                     predicate = NSPredicate(format: "invoiceNumber contains %@ OR invoiceCustName contains %@ OR invoiceStatus contains %@ OR invoiceDateCreated >= %@",searchString,searchString,searchString,searchString)                 }                 else if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "invoice Number" {                     predicate = NSPredicate(format: "invoiceNumber contains %@",searchString)                 }                 else if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "invoice Customer"{                     predicate = NSPredicate(format: "invoiceCustName contains %@",searchString)                 }                 else if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "invoice Status"{                     predicate = NSPredicate(format: "invoiceStatus contains %@",searchString)                 }                 else if (invoiceSearchField.cell as? NSSearchFieldCell)?.placeholderString == "Invoice Date"{                       predicate = NSPredicate(format: "invoiceDateCreated >= %@", searchString as CVarArg)                 }                 invoices = (self.backUpInvoices as NSArray).filtered(using: predicate) as! [Invoice]             }             invoiceCount = "Found \(items.count ) Invoices"             invoiceStatusLabel.stringValue = invoiceCount             self.tableView.reloadData()     } InvoiceDateCreated is defined by the following within a NSObject class: @objc   var invoiceDateCreated: Date? = Date() The error I get when trying to search on date is 2022-09-26 09:14:36.638553-0500 CashToMe[9107:6838576] [General] -[NSTaggedPointerString objCType]: unrecognized selector sent to instance I have read through the following documentation Apple Doc for NSPredicate How can I fix this. Also, if there is a better/newer way to code this I am open to changing the code. Thanks
Replies
4
Boosts
0
Views
2k
Activity
Sep ’22
How to add an IBAction to a macOS tableView Cell
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?
Replies
4
Boosts
0
Views
1.4k
Activity
Nov ’22
macOS Xcode 14.2 app applicationwillterminate function is not called
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
Replies
4
Boosts
0
Views
1.5k
Activity
Jan ’23
Populate one column based on values of other column in a NSTableView
How do you populate one column based on values of other column for a macOS app using Xcode 12 in a tableView? The value of the first column comes from a comboBox which I get control by using the following code connected to the comboBox: @IBAction func comboAction(_ sender: NSComboBox) {         print("Combo selected", sender.selectedTag(), sender.stringValue, sender.indexOfSelectedItem, sender.identifier as Any)         } Then base on the value of the comboBox column within the comboAction function I want to populate column 2. Can this be done? If so, how
Replies
3
Boosts
0
Views
819
Activity
Mar ’21
How to Initialize a structure with in a class?
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"]     }      }
Replies
3
Boosts
0
Views
887
Activity
Nov ’22
How to change the text color for SwiftUI Chart's legend text?
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?
Replies
3
Boosts
0
Views
3.4k
Activity
Nov ’22
Progress Indicator not working as expected
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
Replies
3
Boosts
0
Views
1.4k
Activity
Jun ’23
Where does SwiftData store the data?
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?
Replies
3
Boosts
3
Views
6.6k
Activity
Jan ’24
How to customize buttons in a SwiftUI view toolbar
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
Replies
3
Boosts
0
Views
1.1k
Activity
Aug ’23