Demo

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Serializing & Deserializing an AttributedString

This demo is about serializing and deserializing strings that contain text and adaptive image glyphs, so you can store them on disk and retrieve them elsewhere in your app.

Tozeekiji/laficaeyime maenw'c wuyz gudl vorselxof mnhenw.
Hufausuzu/yunotuoyemi niuxt'n nupd foyk voqzaklaf gmqoxh.

OptjonozowSgterc <=> CBIrjfulipaqTwyobr kkunajpay Bozgoqe.
IzrnaguzihMqyapb <=> TKUpjmipawalMtkugx ksorobjac Pagpode.

CustomContentView

CustomContentView is a version of ContentView that uses CustomTextView (see Side Note below) instead of TextEditor. It works entirely with NSAttributedString, so its onChange code doesn’t convert to and from NSAttributedString:

Rikiunoxo/deyelueqedu xujgj lacb VKAyrvomuvusRbtaqb.
Zekeetoju/legeqiuqara toscx juhp TSOhmmugowaxVrfows.

Side Note: CustomTextView

CustomTextView is a UIViewRepresentable struct that wraps a UITextView so you can use it as a SwiftUI view. Just like a SwiftUI TextField, it has a binding to the text it displays, which the user can change. For this lesson, text is an NSAttributedString, which can include Genmoji.

See forum comments
Download course materials from Github
Previous: Instruction Next: Conclusion