相关疑难解决方法(0)

Swift:自定义编码器/解码器到字符串资源格式

我一直在玩,Codable并从文件中读取和写入JSON.现在我想写一个Coder可以读写iOS .strings文件的自定义.谁能帮我这个?我发现协议EncoderDecoder,但我不知道我应该实现此:

class StringsEncoder {}

extension StringsEncoder: Encoder {
    var codingPath: [CodingKey?] {
        return []
    }

    var userInfo: [CodingUserInfoKey : Any] {
        return [:]
    }

    func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> where Key : CodingKey {

    }

    func unkeyedContainer() -> UnkeyedEncodingContainer {

    }

    func singleValueContainer() -> SingleValueEncodingContainer {

    }
}

extension StringsEncoder: Decoder {
    func container<Key>(keyedBy type: Key.Type) throws -> KeyedDecodingContainer<Key> where Key : CodingKey {

    }

    func unkeyedContainer() throws -> …
Run Code Online (Sandbox Code Playgroud)

swift swift4 codable decodable encodable

35
推荐指数
1
解决办法
3928
查看次数

标签 统计

codable ×1

decodable ×1

encodable ×1

swift ×1

swift4 ×1