Post

Replies

Boosts

Views

Activity

Reply to How do I properly use class variables?
 I'm trying to avoid the use of a global variable, as that's a poor solution, Please do not forget, using too many class variable is as poor as, or poorer than using a global variable. but I'm starting to wonder if Swift supports the concept of these class variables in the same way that other languages I've used do. What sort of languages are you accustomed? You can write something like this: class Foo { private static var _a: String = "" class var a: String { set { self._a = newValue } get { return self._a } } } class Bar: Foo { func printit() { print(Foo.a) } } Foo.a = "abc" let someBar = Bar() someBar.printit() But not sure if this is what you want.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Coalescing @Published changes?
Thanks for showing the additional code. But unfortunately, your code contains some unknown things: OrderedSet, IncomingMessage, Message, ChatMessageCell. Someone would be able to help you with the currently shown info, but I cannot. Hope your issue would be solved soon. Good luck.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Refresh value in text label from JSON
I can't see it reflected in my app. What do you see instead? As far as I tried your code, the NSTextField itemSalida showed -1, which seems to be the expected value. (I needed to simulate URLSession as I cannot access 192.168.0.15:8080, to fill JSONAny and to correct the JSON text by adding [ and ].) I know that I must perform a function to refresh the data What do you think you must? Your code is enough to update the content of the label. if those values are updated, my app does not show them When or where are those values updated? Other than your loadData?
May ’21
Reply to What is a scope ?
And I receive the following error "Cannot find 'HexagonParameters' in scope" How do I code the the scope for HexagonParameters ? I guess you took the code from a tutorial of SwiftUI and HexagonParameters is a name of a struct. In this case, scope is somewhere in your project. You create a new file named HexagonParameters.swift in your project and put the definition of it into the file. https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Navigation Link - presentationMode.Dismiss problem XCode 12.5
Thanks for showing the new code. I tried it both with Xcode 12.4 and 12.5, and only in case of 12.5, I could see Unable to present. Please file a bug.. But as far as I tried, the app continued working and the message seemed not causing severe damage to the app. I'm not sure, but this message may be ignored as a sort of log noise. Or have you experienced something critical with your app? (Some older report with Unable to present. Please file a bug. said that the subviews closed immediately after the message without touching cancel, I think this is not the case as yours.) When I find something useful about this issue, I will share it. By the way, you have mistakenly marked my previous reply as the solution, which I believe is not. As you have noticed, you cannot unmark it (one bad thing with this site). Unfortunately, SOLVED threads would not be appealing and get less attention from readers. In case you have something critical which needs to be fixed, you should better start a new thread. (Please be careful not to mark it as SOLVED mistakenly.) You should use the Code block (icon ``) when you show some code, easily readable would also affect involving more readers into this issue.
May ’21
Reply to Location permission dialog disappears after 1 second
I tried your code, filling many missing parts by guess, and could not reproduce the issue. The dialog was kept showing until I tapped Allow Once. You may have too simplified your code and something you have not shown is affecting. It is hard to say anything sure, but have you tried using @StateObject instead of @ObservedObject?:     @StateObject var locationManager = LocationManager()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21