[swift-users] Does @IBAction imply @objc?
Sebastian Hagedorn
sebastian at iosphere.de
Fri Mar 4 04:27:53 CST 2016
May I send a ping regarding this question? :)
Thanks for taking a look at this!
> On 09 Feb 2016, at 18:17, Jordan Rose <jordan_rose at apple.com> wrote:
>
> 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?
>
> Jordan
>
>
>> On Feb 9, 2016, at 3:24 , Sebastian Hagedorn via swift-users <swift-users at swift.org <mailto: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 <mailto: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/20160304/589496b5/attachment.html>
More information about the swift-users
mailing list