Post

Replies

Boosts

Views

Activity

Reply to Display Calculated Data in SwiftUI Charts ...
Loli-pop Update :: I believe I resolved my [Loli-pop] SwiftUI Chart issue with the following steps :: 1. Created a [Struct] to hold the identified [Solar Elevation Y-Axis] value in the application’s [Constant Folder]. 2. Created a [State Variable] to [Bind] the chart’s [rawSelectedTimeOfDay]. 3. Created a [Function] to return a [Double] from the [Mock Data] for the identified [Calculated Solar Elevation]. 4. Created the [Loli-pop] in the [Chart] to display the identified [Calculated Solar Elevation] data. 5. Implemented the [.chartXSelection] modifier to engage the [Drag Gesture]. 6. Activated the [.chartXSelection :: .onChange] to identify the [Drag Gesture’s newValue]. 7. The application calls the [Function] to return a [Mock Data Double] for the identified [Drag Gesture’s newValue]. 8. The [.onChange] transfers the identified [newValue] to a [Constant Folder Struct]. 9. The [Loli-pop] retrieves the identified [newValue] from the [Constant Folder Struct]. 10. The application formats the [newValue] to the required decimal places. 11. The application displays the [Loli-pop] with each new [Drag Gesture Value]. // MARK: Create the [Struct] to hold the identified [Solar Elevation] in the [Constant Folder]. struct VerifyTheChartSolarElevationYAxisValue { static var theVerifyTheChartSolarElevationYAxisValue: Double = 0.0 } // End of [struct VerifyTheChartSolarElevationYAxisValue] // MARK: Prepare the [CONTENT VIEW] struct SunElevationChartContentView: View { @State private var rawSelectedTimeOfDay: String? = nil @State private var overallData = Value.theSunElevationMockData() @State private var offsetX = 0.0 @State private var offsetY = 0.0 func getYValueForX(xValue: String) -> Double? { for dataPoint in overallData { if dataPoint.theRequiredTimeOfDay == xValue { return dataPoint.theCalculatedElevation } } return nil } // End of [func getYValueForX(xValue: String) -> Double?] // MARK: Prepare the [BODY VIEW] var body: some View { VStack { Chart { ForEach(overallData) { dataPoint in LineMark( x: .value("h:m:s", dataPoint.theRequiredTimeOfDay), y: .value("Elevation", dataPoint.theCalculatedElevation) ) // End of [LineMark] .interpolationMethod(.catmullRom(alpha: 0)) .foregroundStyle(.yellow) .lineStyle(StrokeStyle(lineWidth: 10)) .opacity(1.00) // [Original Chart Format Code] // MARK: Identify and display the [CHART Loli-pop]. if let rawSelectedTimeOfDay { RuleMark(x: .value("Selected", rawSelectedTimeOfDay)) // MARK: Set the RuleMark [LINE STYLE]. .foregroundStyle(.teal) .opacity(0.8) .lineStyle(.init(lineWidth: 2, miterLimit: 2, dash: [2], dashPhase: 5)) .annotation(position: .top, overflowResolution: .init(x: .fit(to: .chart), y: .disabled)) { VStack(spacing: 4) { Text("Solar Elevation") .font(.system(size: 16, weight: .bold, design: .default)) .foregroundStyle(.white) // MARK: Retrieve and identify the [SOLAR ELEVATION VALUE] to [FORMAT] from the [Constants Folder]. let solarElevation_Value: Double = VerifyTheChartSolarElevationYAxisValue.theVerifyTheChartSolarElevationYAxisValue // MARK: Convert the [SOLAR ELEVATION VALUE] to a [STRING]. // MARK: Set the [STRING FORMAT] to display [Four Decimal Places]. let solarElevation_StringValue = String(format: "%.4f", solarElevation_Value) // MARK: Display the [Converted Double Solar Elevation Text Value] as a [STRING]. Text("\(solarElevation_StringValue)º") .font(.system(size: 12, weight: .bold, design: .default)) .foregroundStyle(.teal) // MARK: Show the selected chart [Time of Day]. Text("\(rawSelectedTimeOfDay)") .font(.system(size: 12, weight: .bold, design: .default)) .foregroundStyle(.orange) } .padding(12) .frame(width: 140, height: 80) .background(RoundedRectangle(cornerRadius: 4).fill(LinearGradient(gradient: Gradient(colors: [Color(.systemBlue), Color(.black)]), startPoint: .top, endPoint: .bottom)).stroke(.black, lineWidth: 6).multilineTextAlignment(.center)) // MARK: Position the [Loli-pop Display Rectangle] in the [CHART]. .offset(x: offsetX - 0, y: offsetY - (-110)) } // End of [.annotation] } // End of [if let rawSelectedTimeOfDay] } // End of [ForEach(overallData) { dataPoint in] // Set the [Chart Frame]. .frame(width: 1088, height: 660) .padding(.top, 10) .padding(.bottom, 4) .padding(.leading, 4) .padding(.trailing, 4) // MARK: Identify the [CHART MODIFIER] to engage the [DRAG GESTURE]. .chartXSelection(value: $rawSelectedTimeOfDay) // MARK: Activate [.onChange]. .onChange(of: rawSelectedTimeOfDay, { oldValue, newValue in // MARK: Activate [getYValueForX] function to identify and retrieve the [Solar Elevation]. // MARK: Create a [Default Value] if [rawSelectedTimeOfDay] selection does not exist. if let theRequiredYAxisValue = getYValueForX(xValue: newValue ?? "00:06:00") { // MARK: Assign [Solar Elevation] to a [Constant] in the [CONSTANT FOLDER]. VerifyTheChartSolarElevationYAxisValue.theVerifyTheChartSolarElevationYAxisValue = theRequiredYAxisValue } // End of [if let theRequiredYAxisValue = getYValueForX(xValue: newValue ?? "00:06:00")] }) // End of [.onChange] } // End of [Chart] } // End of [VStack] } // End of [var body: some View] } // End of [struct SunElevationChartContentView: View] Paris ::
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’25
Reply to Display Calculated Data in SwiftUI Charts ...
NOTE :: I am able to engage two different methods to display the calculated [Chart Data]. NOTE :: Both methods properly illustrate the [Chart Data]. NOTE :: As to which method would be best to engage the chart’s [Loli-pop], I do not know at this moment. The [First Method :: The application’s [Content View] calls the [MOCK Data] to display the [Chart] with the following code :: struct SunElevationChartContentView: View { // Identify the refactored [SWIFT CHARTS MOCK DATA] @State private var overallData = Value.theSunElevationMockData() var body: some View { // Create the [CHART] VStack { Chart(overallData) { // Display the [SOLAR ELEVATION DATA] LineMark( x: .value("h:m:s", $0.theRequiredTimeOfDay), y: .value("Elevation", $0.theCalculatedElevation) ) // A parameter for the Catmull-Rom spline. Use [0] for a [Uniform Spline]. .interpolationMethod(.catmullRom(alpha: 0)) .foregroundStyle(.yellow) .lineStyle(StrokeStyle(lineWidth: 10)) .opacity(1.00) } // End of [Chart(overallData)] } // End of [VStack] } // End of [var body: some View] } // End of [struct SunElevationChartContentView: View] The SwiftUI Chart displays the [Calculated Solar Elevation Values] for each [Time of Day]. The [Second Method :: The application’s [Content View] calls the [MOCK Data] to display the [Chart] with the following code :: struct SunElevationChartContentView: View { // Identify the refactored [SWIFT CHARTS MOCK DATA] @State private var overallData = Value.theSunElevationMockData() var body: some View { // Create the [CHART] VStack { Chart { ForEach(overallData) { dataPoint in // Display the [SOLAR ELEVATION DATA] LineMark( x: .value("h:m:s", dataPoint.theRequiredTimeOfDay), y: .value("Elevation", dataPoint.theCalculatedElevation) ) // A parameter for the Catmull-Rom spline. Use [0] for a [Uniform Spline]. .interpolationMethod(.catmullRom(alpha: 0)) .foregroundStyle(.yellow) .lineStyle(StrokeStyle(lineWidth: 10)) .opacity(1.00) } // End of [ForEach(overallData) { dataPoint in] } // End of [Chart] } // End of [VStack] } // End of [var body: some View] } // End of [struct SunElevationChartContentView: View] The SwiftUI Chart displays the [Calculated Solar Elevation Values] for each [Time of Day]. As a side note, the above [Content View Code] methods do not show the incremental [Structs] to configure the [Chart] to show the [Labels], the [CGRect Vertical Lines], and the [CGRect Horizontal Lines]. For the moment, complete with my last coding issue, I am still trying to determine how to properly engage a [Chart Loli-pop] to display the individual [Solar Elevation] values. I am sure I shall discover a method to present the chart’s [Calculated Data], by employing the [Chart Loli-pop] in the future, using the [First Chart Content View Method], or the [Second Chart Content View Method]. This solution is still a mystery to me, where I did not completely resolve my question … :] As always, thank you for your time reviewing my [Chart Data] issue … :] Best regards, jim_k The resultant calculated Chart Images :: Paris :: Suva Fiji :: Queenstown NZ :: Cairo :: Melbourne :: London ::
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’25
Reply to Display Calculated Data in SwiftUI Charts ...
I previously mentioned, my application creates a [Solar Elevation] and a [Solar Azimuth] for an identifiable map location, based upon the [NOAA] calculations. The results happen to be accurate to the [Hour:Minute:Second], compared to NOAA calculations. The [Compass] view illustrates that success, at the selected location with the requested [Time of Day], and [Location]. I focused on the [Solar Elevation] first to determine how I could translate the calculated data to be displayed in a SwiftUI Chart. My previous attempts to create an [Appended Struct] to display the calculated data in the [Chart] failed miserably, although I managed to correct my error to properly append the [Struct]. As noted, every SwiftUI Chart example I discovered always engaged the [Chart Data] with [Mock Data] to interact with the [Chart]. The examples did not solve my question, but the accumulated information generated ideas for me to try. NOTE :: For the moment, I have not discovered a solution with the following method to display the chart’s calculated [Y-Axis] data with a [Loli-pop], but still exploring. So to possibly resolve my issue, I did the following to display the calculated data in a SwiftUI Chart with my very obscure, but somewhat tedious effective method. Please read my comment as too many incremental steps, and possibly TL:TR … :] I prepared the [Calculated Data] :: 1. The application’s [MySunElevationChart_ViewController] manually identified each six minute time interval. 2. Converted each six minute interval into a 24 hour fraction. 3. Converted the fraction into a formatted date string. 4. Appended each formatted date string to the [theTimeOfDayArray]. 5. Assigned the [theTimeOfDayArray] to a [Struct] in the [Constants Folder]. 6. The application’s [MySunElevationChart_ViewController] calculated the [Solar Elevation] with each six minute interval date fraction. 7. Appended each calculated [Solar Elevation] to the [theCalculatedSunElevationArray]. 8. Assigned the [theCalculatedSunElevationArray] to a [Struct] in the [Constants Folder]. I decided to modify my application’s original static value [MOCK DATA STRUCT] with the embedded [Calculated Data] :: 1. The application’s [MySunElevationChart_ViewController] retrieved the [theTimeOfDayArray]. 2. Isolated and extracted each [Formatted String] at a specified index. 3. Assigned each extracted string value to a [Struct] in the [Constants Folder]. 4. The application’s [MySunElevationChart_ViewController] retrieved the [theCalculatedSunElevationArray]. 5. Isolated and extracted each [Solar Elevation] at a specified index. 6. Assigned each extracted [Solar Elevation] value to a [Struct] in the [Constants Folder]. 7. The application refactored the static value [Mock Chart Data] with each [Formatted String Struct Value], and each [Solar Elevation Struct Value]. 8. The application transfered the [Refactored Mock Data] to the [Chart Content View]. NOTE :: I created several [Structs] to prepare the application to receive and transfer the [Calculated Solar Elevation Values] to the [SwiftUI Chart]. I created [Structs] for the [Solar Time Of Day] and the [Solar Elevation] in the [Constants Folder]. I created [Structs] for the [Solar Time Of Day Array] and the [Solar Elevation Array] in the [Constants Folder]. I created [Structs] for each extracted [Solar Elevation Time] and each extracted [Solar Elevation] in the [Constants Folder] for the refactored [MOCK DATA STRUCT]. // [For example the Time Structs] struct SolarElevationTime_0 { static var theSolarElevationTime_0: String = "" } // End of [struct SolarElevationTime_0] // to the end of the data … struct SolarElevationTime_238 { static var theSolarElevationTime_238: String = "" } // End of [struct SolarElevationTime_238] // [For example the Solar Elevation Structs] struct SolarElevation_0 { static var theSolarElevation_0: Double = 0 } // End of [struct SolarElevation_0] // to the end of the data … struct SolarElevation_238 { static var theSolarElevation_238: Double = 0 } // End of [struct SolarElevation_238] I created a separate function, within the [MySunElevationChart_ViewController] to isolate, and extract each [Time of Day] from the [theTimeOfDayArray] with the following code :: // Identify the [TIME OF DAY ARRAY] from the [CONSTANTS FOLDER] let someRequiredTimeOfDayArray = SolarElevationRequiredTimeOfDayDataArray.theSolarElevationRequiredTimeOfDayDataArray let theTimeOfDayValueAtIndex_0 = (someRequiredTimeOfDayArray[0]) // Transfer the constant to the [Constants Folder Struct] SolarElevationTime_0.theSolarElevationTime_0 = theTimeOfDayValueAtIndex_0 // to the end of the data … let theTimeOfDayValueAtIndex_238 = (someRequiredTimeOfDayArray[238]) // Transfer the constant to the [Constants Folder Struct] SolarElevationTime_238.theSolarElevationTime_238 = theTimeOfDayValueAtIndex_238 I created a separate function, within the [MySunElevationChart_ViewController] to isolate, and extract each [Solar Elevation] from the [theCalculatedSunElevationArray] with the following code :: // Identify the [SOLAR ELEVATION ARRAY] from the [CONSTANTS FOLDER] let someRequiredSolarElevationArray = SolarElevationRequiredDataArray.theSolarElevationRequiredDataArray let theSolarElevationValueAtIndex_0 = (someRequiredSolarElevationArray[0]) // Transfer the constant to the [Constants Folder Struct] SolarElevation_0.theSolarElevation_0 = theSolarElevationValueAtIndex_0 // to the end of the data … let theSolarElevationValueAtIndex_238 = (someRequiredSolarElevationArray[238]) // Transfer the constant to the [Constants Folder Struct] SolarElevation_0.theSolarElevation_238 = theSolarElevationValueAtIndex_238 The application transfers and inserts the [Calculated Chart Data] to the application’s [Mock Data Struct]. I refactored the application’s original static value [Mock Data Struct] in the [HourlySunElevation_MockChartData] Swift File to receive the calculated [Struct] constants. struct Value: Identifiable, Equatable, Hashable { let id = UUID() let theRequiredTimeOfDay: String let theCalculatedElevation: Double static func theSunElevationMockData() -> [Value] { return [Value(theRequiredTimeOfDay: SolarElevationTime_0.theSolarElevationTime_0, theCalculatedElevation: SolarElevation_0.theSolarElevation_0), Value(theRequiredTimeOfDay: SolarElevationTime_1.theSolarElevationTime_1, theCalculatedElevation: SolarElevation_1.theSolarElevation_1), // :: To the end of the data :: Value(theRequiredTimeOfDay: SolarElevationTime_238.theSolarElevationTime_238, theCalculatedElevation: SolarElevation_238.theSolarElevation_238)] } // End of [static func theSunElevationMockData() -> [Value]] } // End of [struct Value: Identifiable, Equatable, Hashable] The application’s [Content View] receives and presents the calculated [Chart Data] :: Continued ::
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’25
Reply to WeatherKit :: DailyForecast :: Sunrise :: ForEach :: Timezone Issue
I resolved my Timezone issue with the following code corrections, marked below the [Commented Code] :: Best regards, jim_k import Foundation import SwiftUI import CoreLocation import WeatherKit struct TestForecastView: View { //let dailyForecast: Forecast<DayWeather> let dayWeatherList: [DayWeather] let timezone: TimeZone var body: some View { Spacer() .frame(height: 10) Text("Sunrise Sunset") .font(.system(size: 24, weight: .bold)) .foregroundStyle(.white) Text("Ten Day Forecast") .font(.system(size: 11, weight: .medium)) .foregroundStyle(.white) Spacer() .frame(height: 4) VStack { //ForEach(dailyForecast, id: \.date) { day in ForEach(dayWeatherList, id: \.date) { dayWeatherItem in LabeledContent { HStack(spacing: 20) { RoundedRectangle(cornerRadius: 10) .fill(Color.orange.opacity(0.5)) .frame(width: 120, height: 5) .padding(.leading, 2) .padding(.trailing, 0) VStack { Image(systemName: "sunrise") .font(.system(size: 24.0, weight: .bold)) .foregroundColor(.yellow) //Text(day.sun.sunrise?.formatted(.dateTime.hour().minute()) ?? "?") Text(dayWeatherItem.sun.sunrise?.localTime(for: timezone) ?? "?") .font(.system(size: 10.0)) } .frame(width: 50, height: 20) VStack { Image(systemName: "sunset") .font(.system(size: 24.0, weight: .bold)) .foregroundColor(.yellow) //Text(day.sun.sunset?.formatted(.dateTime.hour().minute()) ?? "?") Text(dayWeatherItem.sun.sunset?.localTime(for: timezone) ?? "?" .font(.system(size: 10.0)) } .frame(width: 50, height: 20) Spacer() .frame(width: 2) } } label: { //Text(day.date.localWeekDayShort(for: timezone)) Text(dayWeatherItem.date.localDate(for: timezone)) .frame(width: 80, alignment: .leading) .padding(.leading, 30) .padding(.trailing, 0) } .frame(width: 380, height: 52) .background(RoundedRectangle(cornerRadius: 4).fill(LinearGradient(gradient: Gradient(colors: [Color(.systemBlue), Color(.black)]), startPoint: .topLeading, endPoint: .bottomTrailing)).stroke(.black, lineWidth: 6).multilineTextAlignment(.center)) .shadow(color: Color.white.opacity(0.1), radius: 4, x: -2, y: -2) .shadow(color: Color.white.opacity(0.1), radius: 4, x: 2, y: 2) } } .padding(.top, 20) .padding(.bottom, 20) .padding(.leading, 20) .padding(.trailing, 20) .contentMargins(.all, 4, for: .scrollContent) .background(RoundedRectangle(cornerRadius: 10).fill(Color.black.opacity(0.0)).stroke(.gray, lineWidth: 4)) } // End of [var body: some View] } // End of [struct TestForecastView: View] The revised Paris Sunrise and Sunset displays the correct times : As a side note, changing the [sun.sunrise?] to [moon.moonrise?] and [sun.sunset?] to [moon.moonset?] affects the Moon Phase too ... :] Paris Sunrise Sunset :: Paris Moonrise Moonset ::
Topic: App & System Services SubTopic: General Tags:
Aug ’24
Reply to WeatherKit :: DailyForecast :: Sunrise :: ForEach :: Timezone Issue
Hello ... :] Thank you for your quick reply ... For the moment, and forgive my ignorance, but I do not understand how to engage your suggested code, var dateFormat -> Date.FormatStyle { let formatStyle = Date.FormatStyle.dateTime.hour().minute() formatStyle.timeZone = self.timezone return formatStyle } nor as to where I should place the code in the application to allow Text(day.sun.sunrise?.formatted(dateFormat) ?? "?") to be exercised ... ? Placing the raw code anywhere in my application simply generates several warnings, and or error messages. My subsequent question happens to be, should I encase this code in an enum, struct, or class, and then again where ... ? I do recognize Quinn's code example, where Quinn's function code illustrates a timezone time in the user's location, and then produces the equivalent correct time in the selected remote location, using the remote location's timezone identifier, such as "Europe/Paris". My application understands the desired requested remote location timezone, where the application wants to update the selected location's time, relative to the selected location's timezone, but for the moment my application does not correctly illustrate the selected location's sunrise or sunset time, as retrieved from . Addressing my newly discovered and very limited SwiftUI knowledge, I know I cannot introduce a function into a View to generate the desired result. I do appreciate your initial quick reply and suggestion, but I still struggle to understand the solution, and again thank you. Best regards, jim_k
Topic: App & System Services SubTopic: General Tags:
Jul ’24
Reply to Xcode Application Continuous (OSX) Indexing Crash Problem
Another update to this issue ... :] I transferred the PList file application, which creates an initial PList file for my application, to another Mac with 48Gb of RAM, and the file indexed properly without issue. So, I confirmed my Mac Mini with 16Gb of RAM cannot index my file nor build the required PList file. Unfortunately, I must look for another Mac with more RAM to be able to proceed in the future. Not what I wanted, but what I must do ... :] I guess I shall consider this issue as closed ... Best regards, jim_k
Aug ’23
Reply to MapKit, macOS, Swift, Location Services Question
The application [ALERT FILES] are here: // MARK: - [showLocationAutorizationDeniedAlert] (and disable code) func showLocationAuthorizationDeniedAlert() { /// Store the [suppression state] in [userDefaults] to [NOT ASK THIS QUESTION AGAIN] let userDefaultsKey = "dontShowLocationAuthorizationDeniedAlert" /// Check to see whether the [User] answered the question to not see the following code again if UserDefaults.standard.bool(forKey: userDefaultsKey) == false { let alert = NSAlert() alert.messageText = "Location Authorization Denied" alert.informativeText = "Parental Controls ... ?" alert.alertStyle = .critical alert.showsSuppressionButton = true alert.suppressionButton?.title = "Do not show this alert again!" alert.addButton(withTitle: "OK") alert.addButton(withTitle: "Cancel") //alert.addButton(withTitle: "Use default values") let response = alert.runModal() /// Turn off the [ALERT] with [User Default Preferences] setting. if let supress = alert.suppressionButton { let state = supress.state switch state { case NSControl.StateValue.on: UserDefaults.standard.set(true, forKey: userDefaultsKey) default: break } // End of [switch state] } // <=== End of [if let supress = alert.suppressionButton] if response == .alertFirstButtonReturn { print("\n alertFirstButtonReturn (OK Button)") } else { print("Use default values") } // End of [if response == .alertFirstButtonReturn] } // <=== End of [if UserDefaults.standard.bool(forKey: userDefaultsKey) == false] /// Bail and [Return] gracefully return } // <=== End of [func showLocationAuthorizationDeniedAlert()] // MARK: - [showLocationAutorizationRestrictedAlert] (and disable code) func showLocationAuthorizationRestrictedAlert() { /// Store the [suppression state] in [userDefaults] to [NOT ASK THIS QUESTION AGAIN] let userDefaultsKey = "dontShowLocationAuthorizationRestrictedAlert" /// Check to see whether the [User] answered the question to not see the following code again if UserDefaults.standard.bool(forKey: userDefaultsKey) == false { let alert = NSAlert() alert.messageText = "Location Authorization Restricted" alert.informativeText = "Check Parental Control" alert.alertStyle = .critical alert.showsSuppressionButton = true alert.suppressionButton?.title = "Do not show this alert again!" alert.addButton(withTitle: "OK") alert.addButton(withTitle: "Cancel") //alert.addButton(withTitle: "Use default values") let response = alert.runModal() /// Turn off the [ALERT] with [User Default Preferences] setting. if let supress = alert.suppressionButton { let state = supress.state switch state { case NSControl.StateValue.on: UserDefaults.standard.set(true, forKey: userDefaultsKey) default: break } // End of [switch state] } // <=== End of [if let supress = alert.suppressionButton] if response == .alertFirstButtonReturn { print("\n alertFirstButtonReturn (OK Button)") } else { print("Use default values") } // End of [if response == .alertFirstButtonReturn] } // <=== End of [if UserDefaults.standard.bool(forKey: userDefaultsKey) == false] /// Bail and [Return] gracefully return } // <=== End of [func showLocationAuthorizationRestrictedAlert()]
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’23
Reply to bind(_:to:withKeyPath:options:), Swift Error, Xcode 14.3 Mac mini(M1)
After scouring the internet to see whether I could discover a solution with better key words, such as [Binding and NSView], I noticed a quote posted more than five years ago, stating the following: Since KVC and KVO are built on the Objective-C runtime, and since Cocoa Bindings is built on top of KVC and KVO, any properties you want to use Cocoa Bindings with need to be exposed to Objective-C. At the bare minimum, that means adding @objc to the declaration. So, my original [Date] property was set to: var currentTime: Date? I changed the [Date] property to: @objc var currentTime: Date? The application did not crash, but did not show the [Clock and the Calendar] updating. Further reading stated: However, if the property can be changed at runtime, there's an additional hurdle you need to jump through; you need to make sure that the KVO notifications will fire whenever the property's setter is called. Apple's implementation of KVO will use Objective-C magic to automatically add the needed notifications to the setter, but since Swift property accesses aren't guaranteed to go through the Objective-C runtime, you need to add the dynamic keyword for this to work reliably. I changed the [Date] property to: @objc dynamic var currentTime: Date? The application did not crash, and the [Clock and the Calendar] updated properly. Perfect, I now have that knowledge ... :] Again, thank you for your time ... Best regards, jim_k London: Sydney:
Topic: App & System Services SubTopic: General Tags:
May ’23
Reply to Unable to pay for developer account
It is my understanding, where I am unfortunately guessing here about your card types, but if your cards happen to be a VISA or MASTERCARD gift card, where the cards have an assigned value, or where you can add funds to the gift credit card, these credit card types do not contain the user's credit history to check against. For example in my home country, you cannot use a gift credit card to rent a vehicle, therefore you must use a credit card issued by a banking institution, where a credit history or credit card security check becomes available to the seller before a transaction can be engaged. Shopping online with an assigned value gift credit card is different. Sellers just take your gift credit card funds. Using the car rental scenario as an example, if you returned the vehicle to the rental agency after closing hours, where the car rental agency believes you returned the vehicle in a perceived damaged condition, the car rental agency would attempt to use your banking institution credit card to apply incremental funds against your credit card. A car rental company would not be able to assign incremental funds against a gift credit card. Therefore the car rental agency refuses to accept the gift credit card type. Unfortunately, I do not know the full history behind this issue with gift credit cards nor your credit card types, but the user's missing gift credit card history can be an issue in many locations, and at many institutions, which sell services or products. Best regards, jim_k
Feb ’23
Reply to Xcode Application Continuous (OSX) Indexing Crash Problem
An update to this issue ... :] The indexing issue within my PList creation application still exists when my file is very large, where the total dictionaries exceed the ability of the application to process them properly into a single PList file. The application's compilation causes the Mac Mini M1 (16GB) to usurp all the RAM, causing the Mac Mini to crash, especially when another application, such as Safari is active, Xcode is obviously active, and with the OS operating requirements too. I cannot acknowledge the "Force Quit" modal window to deactivate any application. The Mac is completely unresponsive. Therefore I must force the Mac Mini to restart by holding the power button for a few seconds. The issue existed with Xcode 12.5.1, Xcode 13.4.1, and still exists within Xcode 14.1. The application presents a warning message with a large file after a minute or two, while indexing, which states "An internal error occurred. Source editor functionality is limited. Attempting to restore." The warning message does not appear when the total dictionaries in the PList are few, and the Mac Mini does not crash. This total is difficult to determine what the actual passing grade total might be without empirical testing, but for the moment it happens to be less than one half of the current total dictionaries the application tries to submit into the PList. My current PList array of dictionaries total happens to be 8060 records. Still curious as to whether Xcode is limited to the available RAM on my Mac Mini, while processing a file, or could my application be generating a memory leak ... ? Best regards, jim_k
Dec ’22
Reply to macOS Monterey Xcode Update Questions (New Warnings)
Mark ... :] Thank you for the information, but the [copy_read_only] message is still periodic within my current application, and newer test applications. I do now know how this warning affects any application, just yet, but I am sure I shall find out one day. I am uncertain about removing the [sandbox]. Again, thank you for your response. Best regards, jim_k
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to MacOS Structs, Constants, TableView Delegate (Implement a Variable) Question
The code to illustrate better: /// Keep the cellView.textField [AS THE ORIGINAL (IB) VALUES] when each [GREATER THAN] or [LESS THAN] conditional is met: cellView.textField?.textColor = NSColor.white /// Keep the cell font size at [11]. let fontSize = 11 cellView.textField?.font = NSFont.systemFont(ofSize: CGFloat(fontSize)) // Compared to the changed cellView.textField: // Change the [TEXT FIELD COLOUR TO YELLOW] when the [cellView.textField IS EQUAL TO THE COMMON NUMBER] condition is met: cellView.textField?.textColor = NSColor.systemYellow // Change the (TEXTFIELD FONT SIZE) with CGFloat. let fontSize = 12 cellView.textField?.font = NSFont.boldSystemFont(ofSize: CGFloat(fontSize))
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to MacOS Structs, Constants, TableView Delegate (Implement a Variable) Question
As fate would have it, I managed to solve the issue a few hours after I posted the question :] I changed my Struct code in the applications (Constants File) to new base values (I probably did not need to make the change.): struct TheRequestedNumbersToFind { static var theFirstNumber = 0 // <=== Previous value = (10) static let theSecondNumber = 0 // <=== Previous value = (13) static let theThirdNumber = 0 // <=== Previous value = (15) static let theFourthNumber = 0 // <=== Previous value = (22) static let theFifthNumber = 0 // <=== Previous value = (29) static let theSixthNumber = 0 // <=== Previous value = (46) static let theSeventhNumber = 0 // <=== Previous value = (3) } I discovered I could change the (Struct Static Variable) to equal the received variable in the applications (Notification): /// Identify the received (Notification) information for the tableView textField. let theTransferredFirstNumberReceived = notification.object if let theFirstNumberReceived = (theTransferredFirstNumberReceived as AnyObject) as? Int32 { /// Note: The (USER) entered the number (10). print("THE FIRST NUMBER RECEIVED :: \(Int32(theFirstNumberReceived)) \n") // Prints: THE FIRST NUMBER RECEIVED = 10 /// ASSIGN THE REQUESTED NUMBER TO THE (STRUCT VARIABLE) TO CHANGE THE (CONSTANTS FILE STRUCT VARIABLE). /// The "Int(theFirstNumberReceived)" must remain as "Int". TheRequestedNumbersToFind.theFirstNumber = Int(theFirstNumberReceived) print("THE REVISED FIRST STRUCT NUMBER RECEIVED :: \(Int32(TheRequestedNumbersToFind.theFirstNumber)) \n") // Prints : // THE REVISED FIRST STRUCT NUMBER RECEIVED :: 10 } I modified the tableView code for the (first column) to be : /// Identify the (STRUCT CONSTANT) for the (FIRST NUMBER). /// This (STRUCT CONSTANT) works because the constant is recognized /// Change the (STRUCT STATIC VARIABLE) to (EQUAL THE REQUESTED NUMBER). let someFirstNumber = TheRequestedNumbersToFind.theFirstNumber print("First Number Struct Variable Received :: \(someFirstNumber) \n") // Prints : // First Number Struct Variable Received :: 10 This change also removed the incremental errors with the static number (10), which allowed a few numbers not equal to (10), to be erroneously displayed as equal to (10). I can now close this issue ... :] Best regards, jim_k
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21