devxoul / Then

✨ Super sweet syntactic sugar for Swift initializers
MIT License
4.18k stars 290 forks source link

How to use 'do' block? #36

Closed zbangsatz closed 7 years ago

zbangsatz commented 7 years ago

First think I want to say: Thank you! It's awesome.

My trouble is can't use 'do' block. The compile show error "Expected member name following.". Example:

NSUserDefaults.standardUserDefaults().do({ // Do anything with UserDefaults })

devxoul commented 7 years ago

@zbangsatz It's because do is reserved keyword in Swift 2. In order to use do in Swift 2 project, you should use backtick(`).

NSUserDefaults.standardUserDefaults().`do` {
  $0.synchronize()
}