Post

Replies

Boosts

Views

Activity

Comment on Usable screen space in a Mac
this line      usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight      uses ternary operator ; is a condensed form of it then else.  It is equivalent to:     if NSMenu.menuBarVisible() { usableHeight = totalHeight - 23 } else { usableHeight = totalHeight }. Swift programming language explains « The ternary conditional operator is a special operator with three parts, which takes the form question ? answer1 : answer2. It is a shortcut for evaluating one of two expressions based on whether question is true or false. If question is true, it evaluates answer1 and returns its value; otherwise, it evaluates answer2 and returns its value. ». It is very convenient when you have to set a value depending on condition. For instance let color = (score < 10) ? UIColor.red : UIColor.green
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Comment on dfg
Is it a test ? A joke ? A mistake ? A bet ? In any case, not very appropriate for the forum unless you explain your purpose. Have a good day.
Sep ’21
Comment on How to make a button that will print words when i press it.
For more fun, change as:     let citiesEU = ["Paris", "Toulouse", "London", "Milan", "Berlin", "Rome", "Madrid", "Lisbon", "Athens", "Brussels"]            let citiesUS = ["New York", "San Francisco", "Washington", "Dallas", "Cupertino", "Seattle", "Miami", "Chicago", "Detroit", "Phoenix"]                      class Responser: NSObject {     //Method to be called     var tag: Int = 0     @objc func printname() {         var value = "" // 0         switch tag {         case 1: value = citiesEU.randomElement() ?? "No EU city" //  (1...10).randomElement() ?? 1         case 2: value = citiesUS.randomElement() ?? "No US city" //  (11...20).randomElement() ?? 2         default: value = "No city" // 0         }         lbl.text = value // "(value)"     } }
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Comment on How to tap a row in a UIPickerView
TapGesture will activate when you tap anywhere in the picker, on a row which may be different from selection, isn't it ? And tapping will not change the selection. That could be misleading. Or pickerTapped must first identify which row was tapped, which is not so easy. Or limit the tap to the center of the picker which is where the selection is.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Comment on A question about use 'lowerThan' when I learning 'precedencegroup'
That's exactly what the doc states: group must come from another module.    need to be in different modules to allow lowerThan
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Comment on No more mail notification from forum
It's working, but with some glitches: no message sent occasionally.
Replies
Boosts
Views
Activity
Aug ’21
Comment on Usable screen space in a Mac
this line      usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight      uses ternary operator ; is a condensed form of it then else.  It is equivalent to:     if NSMenu.menuBarVisible() { usableHeight = totalHeight - 23 } else { usableHeight = totalHeight }. Swift programming language explains « The ternary conditional operator is a special operator with three parts, which takes the form question ? answer1 : answer2. It is a shortcut for evaluating one of two expressions based on whether question is true or false. If question is true, it evaluates answer1 and returns its value; otherwise, it evaluates answer2 and returns its value. ». It is very convenient when you have to set a value depending on condition. For instance let color = (score < 10) ? UIColor.red : UIColor.green
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Comment on What is the empty field in the new Date Picker?
That just confirms the 2 solutions I proposed.
Replies
Boosts
Views
Activity
Aug ’21
Comment on List Sections
I do not see the link between the screen capture and the code you post for contentView. In addition, there is no section defined in this code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on dfg
Is it a test ? A joke ? A mistake ? A bet ? In any case, not very appropriate for the forum unless you explain your purpose. Have a good day.
Replies
Boosts
Views
Activity
Sep ’21
Comment on How to make a button that will print words when i press it.
For more fun, change as:     let citiesEU = ["Paris", "Toulouse", "London", "Milan", "Berlin", "Rome", "Madrid", "Lisbon", "Athens", "Brussels"]            let citiesUS = ["New York", "San Francisco", "Washington", "Dallas", "Cupertino", "Seattle", "Miami", "Chicago", "Detroit", "Phoenix"]                      class Responser: NSObject {     //Method to be called     var tag: Int = 0     @objc func printname() {         var value = "" // 0         switch tag {         case 1: value = citiesEU.randomElement() ?? "No EU city" //  (1...10).randomElement() ?? 1         case 2: value = citiesUS.randomElement() ?? "No US city" //  (11...20).randomElement() ?? 2         default: value = "No city" // 0         }         lbl.text = value // "(value)"     } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on Create ios Swift Framework independent of Xcode Compiler Version
Did you ask the question on the Swift Forum ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on CoreData not updating when saved (Swift)
OK, you now use the same context.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on Is it possible to make this SwiftUI Code work on iOS?
"MacCatalyst but I am aware that it's not always the most easy"     you're right, but it was designed for this exact goal. It's complex because bridging the 2 OS is not that easy. Maybe, instead of trying to adapt your code you should redesign your app with MacCatalyst. Good luck.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on How to tap a row in a UIPickerView
TapGesture will activate when you tap anywhere in the picker, on a row which may be different from selection, isn't it ? And tapping will not change the selection. That could be misleading. Or pickerTapped must first identify which row was tapped, which is not so easy. Or limit the tap to the center of the picker which is where the selection is.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on MacOs - NSTableView, editing single cell
TableView may work even with delegate not defined. Did you set the delegate ? In addition, please show the code of IBAction. Sender must be        (_ sender: NSTextField)
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on MacOs - NSTableView, editing single cell
Yes, it is view based. Could you post the complete code of your test, so that we can reproduce ?
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on Why do animations not work when deselecting a `UITableViewCell` in a `UITableView` asynchronously?
The detailed explanation you got in         https://stackoverflow.com/questions/69160053/why-do-animations-not-work-when-deselecting-a-uitableviewcell-in-a-uitableview-a     seems relevant: it is a question of how update events are queued in the system. And dispatch changes the way it is handled.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on MacOs - NSTableView, editing single cell
Yes, view based is much simpler !
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21