{"id":35338,"date":"2022-03-22T21:01:03","date_gmt":"2022-03-23T01:01:03","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=35338"},"modified":"2025-10-29T09:38:53","modified_gmt":"2025-10-29T13:38:53","slug":"swift-formatstyle-deep-dive","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/03\/22\/swift-formatstyle-deep-dive\/","title":{"rendered":"Swift FormatStyle Deep Dive"},"content":{"rendered":"<p><a href=\"https:\/\/ampersandsoftworks.com\/posts\/formatstyle-deep-dive\/\">Brett Ohland<\/a> (via <a href=\"https:\/\/iosdevweekly.com\/issues\/550\">Dave Verwer<\/a>):<\/p>\n<blockquote cite=\"https:\/\/ampersandsoftworks.com\/posts\/formatstyle-deep-dive\/\">\n<p>Apple introduced the new <code>FormatStyle<\/code> protocol with iOS 15. It allows for some truly remarkable things to happen when you&rsquo;re converting your data into localized strings.<\/p>\n<p>In true Apple fashion though, details about how to use these new features are lightly documented with few examples.<\/p>\n<p>The breadth and depth that this new functionality has been added to Swift is really nice, Apple has added support for it on nearly all data types in Swift. You also have the ability to create custom <code>FormatStyle<\/code> implementations that allow you to arbitrarily convert types using this functionality.<\/p>\n<\/blockquote>\n<p>He has lots of examples and explanations of what the different options do, in a whole series of posts that&rsquo;s basically a Missing Manual.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/01\/26\/swift-foundation-formatter-improvements\/\">Swift Foundation Formatter Improvements<\/a><\/li>\n<\/ul>\n\n<p id=\"swift-formatstyle-deep-dive-update-2022-06-06\">Update (2022-06-06): <a href=\"https:\/\/twitter.com\/bretto\/status\/1532863359111995393\">Brett Ohland<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/bretto\/status\/1532863359111995393\"><p>I recently expanded and revamped my <code>FormatStyle<\/code> deep-dive you linked to back in May into it&rsquo;s own single-serving site.<\/p><p>Following the grand tradition, it&rsquo;s <a href=\"https:\/\/fuckingformatstyle.com\">fuckingformatstyle.com<\/a> (or <a href=\"https:\/\/goshdarnformatstyle.com\">goshdarnformatstyle.com<\/a>) and it has details on every style with every possible option.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/05\/25\/attributedstring-attribute-scopes\/\">AttributedString Attribute Scopes<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Brett Ohland (via Dave Verwer): Apple introduced the new FormatStyle protocol with iOS 15. It allows for some truly remarkable things to happen when you&rsquo;re converting your data into localized strings. In true Apple fashion though, details about how to use these new features are lightly documented with few examples. The breadth and depth that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2022-03-23T01:01:06Z","apple_news_api_id":"bdcd0f59-cc07-42ec-9ad3-ecb0a7f9a3b2","apple_news_api_modified_at":"2025-10-29T13:38:56Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAQ==","apple_news_api_share_url":"https:\/\/apple.news\/Avc0PWcwHQuya0-ywp_mjsg","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,164,31,2078,30,2077,71,2854,901,1812],"class_list":["post-35338","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-documentation","tag-ios","tag-ios-15","tag-mac","tag-macos-12","tag-programming","tag-swift-foundation","tag-swift-programming-language","tag-swiftui"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=35338"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35338\/revisions"}],"predecessor-version":[{"id":36074,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35338\/revisions\/36074"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=35338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=35338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=35338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}