From d99576d0dd9f3085fd6df93f44dc6b2afb3b4f19 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 14 Oct 2022 18:22:29 -0700 Subject: [PATCH 1/2] updated for 1.4.3 --- Swift-Windows.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Swift-Windows.md b/Swift-Windows.md index f19fee8..75377c6 100644 --- a/Swift-Windows.md +++ b/Swift-Windows.md @@ -215,6 +215,33 @@ To connect this action to your button, you can either edit the XML, or use the m Alternatively, you can `Ctrl`-and-drag from the button's **Button Cell** to the **First Responder** you'll find under **Placeholders**, and select your function `clickClick:` from the list that appears. +### D. Displaying the build version number + +In LunaMac version 1.4.3, I updated the About window to dynamically display the current build number, which is set in `Info.plist`. To make this slightly easier, and because Xcode offers no way to assign unique, meaningful names to window elements, we're first going to set the `Tag` property of the "Using LunaMac" text label to `100`. + +I've seen advice against using tags to identify form elements, but it's consistent and predictable, so I'm sticking with it. Note that the `Tag` property must be an **integer**, so you'll have to keep track of your tag numbers if you decide to use this method in your own projects. + +To programmatically access this label and set its value, we're going to update our `viewDidAppear()` function in `ViewController.swift`. + +We can retrieve the build version from the global `Bundle` object, using `Bundle.main.appBuild`. + +```swift +override func viewDidAppear() { + ... + if (title.contains("Changelog")) { + ... + } + else if (title.contains("About")) { + // set label with version number + if (label.tag == 100) { + label.stringValue = ("Using LunaMac " + Bundle.main.appBuild) + } + } +} +``` + +Launch your application and open the About window, and you'll see the current version number displayed. + Now we need to make a changelog dialog, and the code to load it and its contents. ## III. The Changelog window From 187f41a870af6c7cc8346486ca049fc6a29d4a3b Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 24 Mar 2023 17:08:51 +0000 Subject: [PATCH 2/2] Update 'Home' --- Home.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Home.md b/Home.md index 0976b27..6eae165 100644 --- a/Home.md +++ b/Home.md @@ -316,7 +316,7 @@ I can't take credit for figuring out the math on this. I was lucky to find [this Here's the overview: -1. Use the lunar cycle constant `29.53058770576` and calculate its duration in seconds as `lunarSecs`. +1. Use the lunar cycle constant `29.53058770576` and calculate its duration in seconds as `lunarDays`. 2. Convert date of first full moon in 2000 (January 6 at 18:14 UTC) to unix timestamp as `lunarSecs`. 3. Calculate `totalSecs` which is the time (in seconds) between the user date and the moment of the first new moon in 2000 4. If the result is positive, it's valid, so calculate the modulus (remainder) of `totalSecs` divided by `lunarSecs` , to know the amount of seconds that have passed in the current cycle as `currSecs`.