Post

Replies

Boosts

Views

Activity

Reply to JSONDecoder enum-keyed dictionary bug
They explain here a subtle behaviour (to say the least) of JSONEncoder. https://forums.swift.org/t/encoding-decoding-a-swift-dictionary-to-from-json/39989 A dictionary with Int or String key is encoded as dictionary. But with other type key, it is encoded as an array. That seems to be the case with the enum. I tested by catching error: do { let json = try JSONDecoder().decode(Json.self, from: jsonString.data(using: .utf8)!) print("JSON", json) } catch { print("Error", error) } and got the same error message: Error typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "variations", intValue: nil)], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil)) As you noted, if you replace the key type by String: struct Json: Codable { let variations: [String: String] } Then you get the expected result: JSON Json(variations: ["plural": "tests", "singular": "test"])
Topic: App & System Services SubTopic: General Tags:
Jun ’25
Reply to How to modify the title of a post in the Developer Forums?
You can modify only in the first hour after posting. After, the post cannot be edited. In your case, you could: create a new post with the new title and maybe modified content.It would also be fine to point to the old post. in the old post, make a new answer where you link to the new post, explaining it is more general. IMHO, it is not worth bothering moderator for such a change.
Jun ’25
Reply to Window number too large
Where did you get that windowNumber is UInt32 ? Doc states: var windowNumber: Int { get } On 32-bit platforms, Int is the same size as Int32, and on 64-bit platforms, Int is the same size as Int64. But never a UInt32. Why do you need converting from Int to UInt32 ?
Topic: UI Frameworks SubTopic: General Tags:
Jun ’25
Reply to Developer websites
Do you use a site generator to create your web site ? If so, they usually have tools or plugins to create contact forms. For instance, if you use WordPress: there are templates which include directly a contact form generator or you can add a plugin, such as contact-form 7 and there are detailed tutorials for using: such as: https://wpmarmite.com/en/contact-form-7/ Hope that helps.
Jun ’25