Here’s a simple AttributedString with some formatting: import Foundation let str = try! AttributedString( markdown: “Café **Sol**”, options: .init(interpretedSyntax: .inlineOnly) ) AttributedString is Codable. If your task was to design the encoding format for an attributed string, what would you come up with? Something like this seems reasonable (in JSON with comments): { “text”: “Café […]
Swift’s Codable protocol and its surrounding APIs provide a built-in way to serialize and deserialize Swift values to and and from various formats, including JSON and Plists. Arguably one of the most appealing aspects of Codable is its tight integration with the Swift compiler, which often makes it possible for the compiler to automatically generate […]
One of the major advantages of Swift’s built-in Codable API is how the compiler is able to automatically synthesize many different encoding and decoding implementations when using it. In many cases, all that we have to do to enable a Swift type to be serialized into formats like JSON is to mark it as Codable, […]