Я играл с Codable
и читал и записывал JSON из файла и в файл. Теперь я хотел бы написать пользовательский Coder
, который может читать и записывать файлы iOS .strings
. Кто-нибудь может мне с этим помочь? Я нашел протоколы Encoder
и Decoder
, но я понятия не имею, что мне следует реализовать здесь:
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 -> UnkeyedDecodingContainer {
}
func singleValueContainer() throws -> SingleValueDecodingContainer {
}
}