Greetings and salutations, NSHipsters!
As the year winds down, it's a tradition here at NSHipster to ask you, dear readers, to offer up your favorite tricks and tips from the past year as gifts to your fellow hipsters. With iOS 9, El Capitan, brand new watch- and tvOS's, and the open-sourcing of some minor Apple-related tech, there's bound to be lots to share.
Submit your favorite piece of Swift or @objc
trivia, helpful hints, unexpected discoveries, useful workarounds, useless fascinations, or anything else you found cool this year. Just comment below!
If you need inspiration, try the list from last year, or from the year before, or from the year before that.
새해 복 많이 받으세요! 🎆
The addition of the
where
clause has made my code simple and compact while remaining readable. In addition, it has a broad application in Swift, so that it can be applied in nearly any kind of control-flow statement, such asfor
loop,while
loop,if
,guard
,switch
, and even inextension
declarations. One simple way I like to use it is in myprepareForSegue
method:The combo of unwrapping and performing a condition check is most commonly where I use the
where
clause. Thewhere
clause is not going to change your life, but it should be an easy and useful addition to your Swift skills.