Post

Replies

Boosts

Views

Activity

Reply to A question about use 'lowerThan' when I learning 'precedencegroup'
I try the example, but the 'Range' and 'Comparative' show error: Unknown precedence group Names of groups may have changed to: RangeFormationPrecedence ComparisonPrecedence And this compiles: precedencegroup Additive { higherThan: RangeFormationPrecedence, Equivalence } precedencegroup Multiplicative { higherThan: Additive } // module A precedencegroup Equivalence { higherThan: ComparisonPrecedence // lowerThan: Additive // possible, because Additive lies in another module } infix operator ~ : Equivalence Which confirms what you say about the issue with lowerThan. I don't understand the reason why they need to be in different modules to allow lowerThan. And documentation is really minimal on this. Could be worth a bug report on documentation.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to I’m new
Could you explain more what you want to do ? what is main device ? An iPhone, iPad, Mac ? What is the other device ? Cant you use AirDrop to transfer data ? You tagged Interface builder ? Do you want to transfer day between 2 ViewControllers ?
Aug ’21
Reply to Animate a macOS window
Use NSAnimation. For instance, if you want to animate when clicking a button: @IBAction func startAnimation(_ sender: NSButton) { let fixedDuration = 5.0 // set duration as you want, in seconds NSAnimationContext.runAnimationGroup( { (context) in context.duration = fixedDuration             self.view.window?.animator().setFrame(CGRect(x: 0, y: 0, width: 200, height: 200), display: true, animate: true) }) }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Swift + OS X + Xcode : Change NavigationLink destination and text programtically
import SwiftUI struct ContentView: View { var body: some View { NavigationView { NavigationLink(destination: NextContentView()){ Text("Next View") } } } } Declare a state var and have a test: import SwiftUI struct ContentView: View {     @State var firstPass: Bool = true   var body: some View { NavigationView {             if firstPass  { NavigationLink(destination: NextContentView()){ Text("Next View") } } else { NavigationLink(destination: CurrentView()){ Text("Other View") } } } } }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to How to find physical size of UI element?
You have to do some computation. Here is a table which gives all devices size information. h t t p s : / / w w w.ios-resolution.com Let's consider an example: From screen physical Diagonal (phD), you can compute physical width (phW) and height (phH): we have equation : phW*phW + phH * phH = phD * phD. // Pythagore physical dimensions are proportional to logical dimensions phW = logW * x phH = logH * x Hence we get : x = phD / sqrt(logW*logW + logH * logH) phW = phD / sqrt() physWidth = x * logicalWidth Now that you have physical height and width of screen, as well as logical dimensions, it is easy to compute physical size of UI element: if it is h and w (in points) itemPhyWidth = w * physWidth / logicalWidth, or with previous formulae itemPhyWidth = w * x itemPhyHeight h * x Hope that helps.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Usable screen space in a Mac
Try the following let usableHight = NSMenu.menuBarVisible() ? totalHight - 23 : totalHight Here is a simple test that works: let totalHeight = 400 var usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) NSMenu.setMenuBarVisible(false) usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight)
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Usable screen space in a Mac
Try the following let usableHight = NSMenu.menuBarVisible() ? totalHight - 23 : totalHight Here is a simple test that works: let totalHeight = 400 var usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) NSMenu.setMenuBarVisible(false) usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) yields: 377 hides menu bar 400
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to OS X + Swift + Xcode : Programmatically transition from one view controller to another
Code in the IBAction should be like: let storyBoard = NSStoryboard(name: "Main", bundle: nil) as NSStoryboard let secondController = storyBoard.instantiateController(withIdentifier: "secondVC")     self.presentAsModalWindow(secondController, animated: true, completion: nil) Don't forget to remove the segue from the button.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to No more mail notification from forum
@Frameworks Engineer  Unfortunately, all has not been fixed yet. No notification received when answer marked as correct.
Replies
Boosts
Views
Activity
Aug ’21
Reply to A question about use 'lowerThan' when I learning 'precedencegroup'
I try the example, but the 'Range' and 'Comparative' show error: Unknown precedence group Names of groups may have changed to: RangeFormationPrecedence ComparisonPrecedence And this compiles: precedencegroup Additive { higherThan: RangeFormationPrecedence, Equivalence } precedencegroup Multiplicative { higherThan: Additive } // module A precedencegroup Equivalence { higherThan: ComparisonPrecedence // lowerThan: Additive // possible, because Additive lies in another module } infix operator ~ : Equivalence Which confirms what you say about the issue with lowerThan. I don't understand the reason why they need to be in different modules to allow lowerThan. And documentation is really minimal on this. Could be worth a bug report on documentation.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to I’m new
Could you explain more what you want to do ? what is main device ? An iPhone, iPad, Mac ? What is the other device ? Cant you use AirDrop to transfer data ? You tagged Interface builder ? Do you want to transfer day between 2 ViewControllers ?
Replies
Boosts
Views
Activity
Aug ’21
Reply to Animate a macOS window
Use NSAnimation. For instance, if you want to animate when clicking a button: @IBAction func startAnimation(_ sender: NSButton) { let fixedDuration = 5.0 // set duration as you want, in seconds NSAnimationContext.runAnimationGroup( { (context) in context.duration = fixedDuration             self.view.window?.animator().setFrame(CGRect(x: 0, y: 0, width: 200, height: 200), display: true, animate: true) }) }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Attempt to map database failed
Could it be that    nicely formatted printable attributed string.     requires images entitlement ? Could you try without the nice formatting ?
Topic: Code Signing SubTopic: Entitlements Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to iOS 15 (Beta) PDFKit 'insertPage:atIndex:' issue
Does it occur as well on simulator ? Could you show the code for appending pages, so that we may try to reproduce and confirm ?
Replies
Boosts
Views
Activity
Aug ’21
Reply to Swift + OS X + Xcode : Change NavigationLink destination and text programtically
import SwiftUI struct ContentView: View { var body: some View { NavigationView { NavigationLink(destination: NextContentView()){ Text("Next View") } } } } Declare a state var and have a test: import SwiftUI struct ContentView: View {     @State var firstPass: Bool = true   var body: some View { NavigationView {             if firstPass  { NavigationLink(destination: NextContentView()){ Text("Next View") } } else { NavigationLink(destination: CurrentView()){ Text("Other View") } } } } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to find physical size of UI element?
You have to do some computation. Here is a table which gives all devices size information. h t t p s : / / w w w.ios-resolution.com Let's consider an example: From screen physical Diagonal (phD), you can compute physical width (phW) and height (phH): we have equation : phW*phW + phH * phH = phD * phD. // Pythagore physical dimensions are proportional to logical dimensions phW = logW * x phH = logH * x Hence we get : x = phD / sqrt(logW*logW + logH * logH) phW = phD / sqrt() physWidth = x * logicalWidth Now that you have physical height and width of screen, as well as logical dimensions, it is easy to compute physical size of UI element: if it is h and w (in points) itemPhyWidth = w * physWidth / logicalWidth, or with previous formulae itemPhyWidth = w * x itemPhyHeight h * x Hope that helps.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to find physical size of UI element?
Some computation on an example, on iPhone 12, a label with 34 points height: x = 6.06 / √(390390 * 844844) = 0.0065" = 0.0165 cm h = 34 * x = 0.56 cm
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Usable screen space in a Mac
Did you try to use menuBarVisible ? https://developer.apple.com/documentation/appkit/nsmenu/1518236-menubarvisible
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Usable screen space in a Mac
Try the following let usableHight = NSMenu.menuBarVisible() ? totalHight - 23 : totalHight Here is a simple test that works: let totalHeight = 400 var usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) NSMenu.setMenuBarVisible(false) usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Usable screen space in a Mac
Try the following let usableHight = NSMenu.menuBarVisible() ? totalHight - 23 : totalHight Here is a simple test that works: let totalHeight = 400 var usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) NSMenu.setMenuBarVisible(false) usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) yields: 377 hides menu bar 400
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to stop an animation
Did you manage to stop the animation with this solution ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to Can someone answer this stack overflow question?
The correct practice on the forum is to post the question, in addition to the link.
Replies
Boosts
Views
Activity
Aug ’21