Post

Replies

Boosts

Views

Activity

Reply to Spin wheel
You have a range of options but first describe what you're doing with the Spin Wheel? By Answering this we will known if you're referring to an item picker for dates and time, or some kind of data model or as Claude31 suggested an activity indicator to indicate there is some kind of background or UI processing taking place.
May ’22
Reply to Create a func which totals the value of data
Because you're calling your code in the viewDidLoad override, firstLoad is not required. The viewDidLoad only gets called once and only once per instance. firstLoad and points: [Atkie]() should be instances of the view controller and not globals. One of the nice things about swift are its high order functions. The calculateSumPoints method can be rewritten as follows: func calculateSumPoints() {     let sum = points.compactMap { $0.point } // this remove any nil point string values from the collection         .reduce(0) { previous, next in // using reduce we access to the previous and current value             guard let value = Int(next) else { return previous } // unwrap next as an Int if it fails return the previous calculation             return previous + value // return the sum of the previous value and the next value         }     totalPoints.text = "\(sum)" }
Topic: Programming Languages SubTopic: Swift Tags:
May ’22
Reply to SwiftUI TableColumn with Custom Widget not able to Bind
Using a TableColumn requires a Table {// content } rows: { // data source } pattern similar to below. Where in the example rowItems is a collection of Items for the data source. Items struct Item { let from: Date let to: Date let hours: Double } // The table view Table(selection: $selection, sortOrder: $sortOrder) { // Sort column on \.from key value path of item             TableColumn("From", value:\.from) { item in                 Text(item.from(date: .numeric, time: .omitted))             } // Sort column on \.to key value path of item             TableColumn("To", value:\.to) { item in                 Text(item.to.formatted(date: .numeric, time: .omitted))             } // Sort column on \.hours key value path of item             TableColumn("Total", value:\.hours) { item in                 Text(item.hours)             }         } rows: { // Populate the rows data source with TableRow types containing an item type from the rowItems collection which is passed on each TableColumm.             ForEach(rowItems) { item in                 TableRow(item)             }         } See Apple example code here: https://developer.apple.com/documentation/swiftui/building_a_great_mac_app_with_swiftui
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’22