While working on the iOS Development with Swift book I decided on this code for an example I'm using in the chapter that talks about composing views together. This is a silly little scroll view that displays a user's bio, and is actually used by a ProfileView
that contains this and a UserDetailsView
.
On line 19 I'm creating the setter for the text
property that basically is meant to act as a way to apply default attributes to a plain string and assign it to the bio label's attributedText
property.
I started making the NSAttributedString
and was ready to have to do a bunch of build up crap to build the dictionary first and the paragraph style and such, and then I realised… SELF-INVOKING CLOSURES! I personally feel this is a bit more "Swift-y" and I was actually really impressed with the fact the type system didn't get in the way here, though that's just because of the context really (type is [AnyObject:AnyObject]
).
Would love all your thoughts.