[swift-users] Does @IBAction imply @objc?

Jordan Rose jordan_rose at apple.com
Tue Feb 9 11:17:16 CST 2016

Hm. There are several levels to this answer:

- The implementation of @IBAction uses @objc.
- In theory we could some day have @IBActions that do not use the ObjC runtime.
- But I agree that having to type "@IBAction @objc private func foo…" seems like a bit much.

Doug, what do you think?


> On Feb 9, 2016, at 3:24 , Sebastian Hagedorn via swift-users <swift-users at swift.org> wrote:
> I’m currently migrating some code to the new #selector syntax and came across an issue re: @objc visibility.
> I have this method:
> @IBAction private func tapGestureRecognized(gesture: UIGestureRecognizer) {…}
> …and use this code to set up the recognizer:
> let tapSelector = #selector(MyClass.tapGestureRecognized(_:))
> let tapGesture = UITapGestureRecognizer(target: self, action: tapSelector)
> The previous version with Selector(“…") worked fine. Now that I use #selector, I get this warning:
> Argument of '#selector' refers to a method that is not exposed to Objective-C
> My understanding was that @IBAction always implied @objc. I can easily fix the warning, either by adding @objc or by removing the private modifier, but I’d like to understand why @objc @IBAction works, but @IBAction does not. I’d like to keep the private modifier. If this is a bug/limitation, I will file a bug report. Just wanted to make sure that I understand it correctly.
> Cheers
> Sebastian
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160209/25a6b7ba/attachment.html>

More information about the swift-users mailing list