πWWDC21 | Category : Foundation
π https://developer.apple.com/videos/play/wwdc2021/10109/
π Discover how the latest updates to Foundation can help you improve your app's localization and internationalization support. Find out about the new AttributedString, designed specifically for Swift, and learn how you can use Markdown to apply style to your localized strings. Explore the grammar agreement engine, which automatically fixes up localized strings so they match grammatical gender and pluralization. And we'll take you through improvements to date and number formatting that simplify complex requirements while also improving performance.
- Characters
- Ranges
- Dictinary
Attributed string allow you to associate attributes, which are key-value pairs, to a specific range of a string. The most common attributes are defined by the SDK, but you can also create your own.
- Value type
- Compatible with String
- same character-counting behavior as Swift String
- Localizable
- Safety and security
- both compile time safety by using strong typing and also safety during unarchiving using Codable.
- Chracters - which provides addess to the string, and runs, which provides a access to the attributes
- Runs - functions that you are familiar with from types like Array are availble here two.
Localizable
- NSAttributedString
- Codable
- Custom attributes
That defines what type of value is requires and a name for archiving
- Declares type of value
- Customizes encoding behavior
- Group of attribute keys
- Defined by each framework or app
- Fields
- Order does not matter
- Sensible default
- Add fields to customize