I am seeing a problem with the new #selector syntax (latest development snapshot 2016-05-02):
It is not possible to put selectors in an array anymore it seems (example for checking an action against a list of selectors):
and Xcode reports:
...MainWindowController.swift:132:53: Expected '#]' at end of object literal expression
...MainWindowController.swift:132:53: Expected 'let' or 'var' in conditional; use '&&' to join boolean conditions
...MainWindowController.swift:132:133: Braced block of statements is an unused closure
...MainWindowController.swift:132:133: Expression resolves to an unused function
The old syntax works fine:
Was this change expected?
Thanks for looking into it,
On 29 Jan 2016, at 01:17, Douglas Gregor via swift-dev <firstname.lastname@example.org> wrote:
On Jan 28, 2016, at 3:48 PM, Jordan Rose <email@example.com <mailto:firstname.lastname@example.org>> wrote:
On Jan 28, 2016, at 12:12, Douglas Gregor via swift-dev <email@example.com <mailto:firstname.lastname@example.org>> wrote:
I’ve finished the implementation of SE-0022, the #selector expression. Part of that proposal is the deprecation of the use of string literals to form Selectors, which is something we would like to do in Swift 2.2 (so that we can remove it outright in Swift 3).
However, it’s a non-trivial set of changes, and I’d like review of the corresponding commits before pulling it into the branch. The commits are:
https://github.com/apple/swift/commit/dccf3155f1fe5400df0c9b51f21a3b8f7fa09b9c (Jordan reviewed this)
https://github.com/apple/swift/commit/1a830fa541705594bd4b3936de24a20b5b943059 (Jordan reviewed this)
I reviewed all of these except
I will say I'm not happy that we don't have any real code completion or IDE support. That seems important for putting it into a release.
The code completion we have is just filling in the “selector(@objc method)” after “#” in expression contexts, which is very weak. There are two things we want:
* Better code completion in general for compound names, e.g., after “UIView.”, we probably want to see (or have some easy way to get to) the compound name “insertSubview(_:aboveSubview:)”. That’s really SE-0021 not having good code completion.
* Within #selector(…), we want to see compound names as the primary completions after a type name, and limit to @objc methods.
swift-dev mailing list