Swift: Adding a selector for a private target makes an unrecognized selector crash

Originator:ldesroziers
Number:rdar://18536925 Date Originated:10/03/2014
Status:Resolved Resolved:yes
Product:Developer Tools Product Version:
Classification: Reproducible:Not Applicable
 
APPLE DEV RELATION 07-Oct-2014 04:14 PM

Engineering has determined that this issue behaves as intended based on the following:

You can add the 'objc' attribute to any method or property to explicitly expose that member to the Objective-C runtime. This can be used no matter what the accessibility is.

Please update your bug report to let us know if this is still an issue for you.


ORIGINAL RPOBLEM:

Using Swift, you can't assign a custom action to a private target, unless making this action "internal" or "public" which causes, of course, a warning in Xcode because we're "declaring an internal (or public) instance method for a private class"

The problem is: not doing so causes the code to crash on run


1. Create a private UIView subclass
2. Add a gesture recognizer to it with target: self, selector "youChoose:"
3. Implement your selector
4. Run the app and trigger the gesture's action -> Crash

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!