{"id":25780,"date":"2019-06-25T16:47:08","date_gmt":"2019-06-25T20:47:08","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=25780"},"modified":"2019-06-27T16:39:24","modified_gmt":"2019-06-27T20:39:24","slug":"swift-property-wrappers","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/06\/25\/swift-property-wrappers\/","title":{"rendered":"Swift Property Wrappers"},"content":{"rendered":"<p><a href=\"https:\/\/nshipster.com\/propertywrapper\/\">Mattt Thompson<\/a>:<\/p>\n<blockquote cite=\"https:\/\/nshipster.com\/propertywrapper\/\"><p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0258-property-wrappers.md\">SE-0258: Property Wrappers<\/a> is currently in its third review (scheduled to end yesterday, at the time of publication), and it promises to make open up functionality like <code>lazy<\/code> so that library authors can implement similar functionality themselves.<\/p><p>The proposal does an excellent job outlining its design and implementation. So rather than attempt to improve on this explanation, we thought it&rsquo;d be interesting to look at some new patterns that property wrappers make possible &mdash; and, in the process, get a better handle on how we might use this feature in our projects.<\/p>\n<\/blockquote>\n\n<p>This is one of my favorite new Swift features, although there are some issues:<\/p>\n\n<blockquote cite=\"https:\/\/nshipster.com\/propertywrapper\/\">\n<p>As described in the previous section,\n  property wrappers have but two methods of recourse\n  to deal with invalid values:<\/p>\n<ol>\n  <li>Ignoring them (silently)<\/li>\n  <li>Crashing with <code>fatalError()<\/code>\n<\/li>\n<\/ol>\n<p>[&#8230;]<\/p>\n<p>Attempting to compose two property wrappers that act on <code>String<\/code> values fails,\n  because the outermost wrapper is acting on a value of the innermost wrapper type.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/06\/03\/swiftui-and-combine\/\">SwiftUI and Combine<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Mattt Thompson: SE-0258: Property Wrappers is currently in its third review (scheduled to end yesterday, at the time of publication), and it promises to make open up functionality like lazy so that library authors can implement similar functionality themselves.The proposal does an excellent job outlining its design and implementation. So rather than attempt to improve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2019-06-25T20:47:11Z","apple_news_api_id":"f6ff3a67-3403-48b2-8501-6c24cb0bf354","apple_news_api_modified_at":"2019-06-27T20:39:28Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/A9v86ZzQDSLKFAWwkywvzVA","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":[46,71,901],"class_list":["post-25780","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25780","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=25780"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25780\/revisions"}],"predecessor-version":[{"id":25803,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25780\/revisions\/25803"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=25780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=25780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=25780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}