Stringified selectors are deprecated
About 2 min
Stringified selectors are deprecated 관련
HACKING WITH SWIFT
What's new in Swift?
Stringified selectors are deprecated | Changes in Swift 2.2
Stringified selectors are deprecated
Available from Swift 2.2
One unwelcome quirk of Swift before 2.2 was that selectors could be written as strings, like this:
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Tap!", style: .Plain, target: self, action: "buttonTaped")
If you look closely, I wrote "buttonTaped"
rather than "buttonTapped"
, but Xcode wasn't able to notify me of my mistake if either of those methods didn't exist.
This has been resolved as of Swift 2.2: using strings for selectors has been deprecated, and you should now write #selector(buttonTapped)
in that code above. If the buttonTapped()
method doesn't exist, you'll get a compile error – another whole class of bugs eliminated at compile time!
Other changes in Swift 2.2…
++ and -- are deprecated | Changes in Swift 2.2
++ and -- are deprecated
Traditional C-style for loops are deprecated | Changes in Swift 2.2
Traditional C-style for loops are deprecated
Comparing tuples | Changes in Swift 2.2
Comparing tuples
Tuple splat syntax is deprecated | Changes in Swift 2.2
Tuple splat syntax is deprecated
More keywords can be used as argument labels | Changes in Swift 2.2
More keywords can be used as argument labels
Variable parameters have been deprecated | Changes in Swift 2.2
Variable parameters have been deprecated
Renamed debug identifiers: line, function, file | Changes in Swift 2.2
Renamed debug identifiers: line, function, file
Compile-time Swift version checking | Changes in Swift 2.2
Compile-time Swift version checking