#Codable

2025-03-04

My CodableWrappers library was featured on this month’s Swift.org community showcase! swift.org/packages/showcase.ht check it out here if you’re looking to improve Codable ergonomics 🤓: swiftpackageindex.com/GottaGet #swiftlang #swift #codablewrappers #oss #github #iosdeveloper #codable

2025-03-04

Groc 3 xAI в разработке iOS приложения «Страны Мира» (отображение границ)

В предыдущей статье я писала о создании довольно простого тестовое iOS приложение Countries, которое показывает все страны Мира по регионам (Европа, Азия, Латинская Америка и т.д.) и для каждой страны её название и флаг. Если вы выбираете какую-то страну, то о ней сообщается дополнительная информация о численности населения population и размере ВВП (валового внутреннего продукта) gdp. Я хочу добавить на карту границы страны. На данный момент я ничего не знаю о том, где взять информацию о границах стран, но это должен быть либо JSON файл, либо JSON информация из интернета, которую можно считать с помощью async / await и декодировать в Swift. Я хочу обратиться к Groc 3 xAI и попросить его написать для меня Swift код, который бы добавил границы выбранной страны на карту. Забегая вперед, скажу, что Groc 3 xAI практически полностью справился со всеми моими запросами, предложив совершенно неожиданное для меня решение со встроенным в MapKit декодером MKGeoJSONDecoder. Тем не менее я попросила Groc 3 создать Codable Модель в Swift для декодирования GeoJSON данных, и он с ней превосходно справился. По ходу дела Groc 3 вообще выдал целый "Комплексный обзор о получении GeoJSON данных стран" и предоставил очень четкие "рассуждения", которые вполне можно использовать как отличный обучающий материал.

habr.com/ru/articles/887094/

#Groc_3 #ии #ios_разработка_swift #Groc #ai #map #codable #JSONDEcoder

Dave DeLongdavedelong
2024-08-18

Today I am reminded, once again, that is a terrible API that should be excised from the language with extreme prejudice.

It's a shame that Swift 6 is already "done”; it would've been the perfect time to do it.

2024-07-27

#Swift #Codable

I confess

I have gotten by in my Swift career with having written very few custom Codables

I was writing one today and it mostly went OK

But there is a language/API wart when iterating over children of an unkeyed container

I got to this part of the API and I went “WTF, who does it like that”

Shouldn’t it be like a Sequence or something, so I could do “for nestedContainer in container” or something like that

Custom Swift Codable with nested containers
2024-05-15

Parsing JSON Data is a fundamental in modern SwiftUI apps. This comprehensive guide covers all the aspects of the Codable protocols in Swift.

#JSON #Programming #Swift #SwiftUI #macOS #iOS #visionOS #Codable
matteomanferdini.com/swift-par

2024-03-11

And now a simple but pretty thorough implementation of an Encoder with tests. (Although still more of a toy / somewhere to start than something anyone should use.)

- whynotestflight.com/excuses/an

- github.com/carlynorama/CoderEx

It goes on forever. As I say in the summary 1578 lines down: "Encoders. Not so fiddly if one can be ruthless in vetting the input. Interminable to write if trying to be general purpose. "

And this one isn't even configurable!

, ,

2024-03-06

Continuing on with that WebExtension, but with a detour in custom Encoders

whynotestflight.com/excuses/ho

Found the best thing for it was copying and making crazy graphs of some existing encoders in the Apple/GitHub repos. Here's 4

I found the comparison between the two different JSONEncoder implementations particularly interesting.

, , , , ,

Crazy graph of the JSONEncoder code with multicolored boxes and arrows everywhere. (FoundationEssentials version.)Crazy graph of the JSONEncoder code with multicolored boxes and arrows everywhere. (5.10 release version.)A chart of all the parts of the URIEncoder from the SwiftOpenAPIGenerator. Like the JSONEncoders, lots of colored boxes and arrows.Many fewer colored boxes and arrows. A simplified theoretical encoder.
Ramesh #NotGoingBackrameshgupta
2023-09-08

@vij

That's what I keep telling myself for lack of (Core Data supports it) and lack of auto-synthesized support.

Not complaining at all, as I am happy to take whatever Apple has provided so far in this initial beta release of . I know much of my boilerplate code for (de)serialization will vanish at some point, and I wouldn't mourn the loss 😀 Happy now. Happy later!

2023-08-24

Wusstest du, dass die richtige Verwendung des Codable-Protokolls dir helfen kann, effizient mit JSON-APIs zu arbeiten? Sei dabei, wenn @5sw in seinem Vortrag wertvolle Tipps und Tricks teilt!

Hol Dir jetzt Dein Ticket: macoun.de/anmelden

#Codable #AppEntwicklung #JSONAPIs #Effizienz #macounFFM

Uli Kusterer (Not a kitteh)uliwitness@chaos.social
2023-04-20

You know how conforming to Codable makes it so any UIView subclass has to implement codable (even if it just is to fatalError() because you only ever plan to create the view in code).

Is there a good #Swift design pattern for creating class hierarchies like that? Where the base class supports and implements a feature, but you don't want subclasses to be forced to provide it?

#swiftLang #codable #designPatterns #programming

Nero WolfeNeroWolfe
2023-03-02

Sometimes generics are very useful

2023-02-28

#Swift #Codable

Is this weird? Or normal?

I needed a type which is codable so I can archive/transmit it in various ways, which boxes a result with noncodable types.

Making a Codable type out of a Result with noncodable types.
Rhett Rogersrhett@rogersfam.co
2022-12-23

More work on my app.

Been trying to set it up so #CoreData objects can be created and updated from the objects sent from the API using the #Codable protocol.

It has had its headaches but I got it mostly set up, even to the point of updating existing objects in the data store.

My issue comes when I hit a collection of objects. I’m not sure how to handle inside of the init(from: Decoder) when some or all of those objects are already in my store

#Swift

2022-05-02

Touching some #Swift #Codable code again… and wondering why the Codable design forces all type to have exactly one encode/decode strategy. Is it assuming that the type owner knows best?

The .dateDecodingStrategy mess seems basically what happened because one have multiple strategies that coexist; but user-level types don’t have that magic…
Hmm…

Barry BrownBarrybrown
2018-09-01

TIL "Expected to decode Int but found a number instead." error in the Xcode console means JSONDecoder expected a Bool when the type was set to Int.

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst