Post

Replies

Boosts

Views

Activity

Reply to Codable with superclass doesn't work ??
What does your JSON look like? Have you tried pasting a sample of it into https://app.quicktype.io to see what it generates? When I convert any JSON into objects I always mark it as Codable. It's possible that B.y = "a value" might be in your JSON, but B itself is not Codable and so cannot be used to code the JSON in the first place.
Aug ’24
Reply to Carplay Whatsapp
WhatsApp is a third-party app; it's not an Apple app. It's likely that WhatsApp needs to be updated to work with iOS 18. Since iOS 18 is currently in beta, WhatsApp cannot release an update that would make it work with iOS 18. You will have to wait for iOS 18 to be released and then wait for WhatsApp to release their update for it to work properly. Besides, if there is an issue with a third-party app, you should really tell the developer of that app so they know, and can fix it.
Aug ’24
Reply to Codable with superclass doesn't work ??
Your JSON doesn't require two different classes, and doesn't match what you're trying to do in your code. What Swift is likely doing is seeing your Codable A class with the x variable, and populating that. The y var is nil because there is no y var in the only Codable class in your code. If your JSON was: { "A": { "x": "foo" }, "B": { "y": "bar" } } You'd use something like: struct RootClass: Codable { let a: A let b: B enum CodingKeys: String, CodingKey { case a = "A" case b = "B" } } struct A: Codable { let x: String } struct B: Codable { let y: String } Both are Codable, and will correctly parse that updated JSON. Since your JSON is { "x": "foo", "y": "bar" } you should just be using: struct RootClass: Codable { let x, y: String }
Aug ’24
Reply to Metric Crash by Widget SwiftUI
Have you removed items one at a time to see if the crash happens? In other words, remove the Image and see if it crashes. If not, it's the Image causing the issue. If not, remove the Text, etc. If it still crashes, then remove all attributes and add them back one at a time until it crashes. As an aside, your code can be cleaned up a little: I doubt you need the clear backgrounds. foregroundColor() is deprecated. You should use foregroundStyle() instead. .onAppear {} doesn't seem to have anything in it, so remove it. (You may have removed the contents for this post.) VStack(){ doesn't need empty parentheses, so can be VStack {. Does defaultImage exist as a UIImage? Are your frame sizes valid? That might trigger metrics issues.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’24
Reply to Selecting WindowGroup to open at app startup.
Do you need two WindowGroups? Can you put the if statement inside one WG, and apply it to the Views instead? @AppStorage("showFirstView") private var showFirstView = true var body: some Scene { WindowGroup(id: "wg") { if showFirstView { ViewOne() } else { ViewTwo() } } } I have no idea if this will work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’24