Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build an Interactive Story App with Swift Creating the User Interface Programmatically Continuing Our Story

Alex Busu
PRO
Alex Busu
Pro Student 11,819 Points

How to make it work in XCode 9.1 with Swift 4

When attempting to addTarget to our first choice button there's an error that pops up around the # selector

'#selector' refers to a method that is not exposed to Objective-C

To fix this we need to add @objc in front of our function declarations.

e.g. @objc func loadFirstChoice() { ....

Can I ask what this is and why it works? I have read that @objc was implicitly assigned until swift 4. Why and what how does it affect us?

4 Answers

Jonathan Mazala
Jonathan Mazala
9,860 Points

i just clicked "Fix" and it worked.

I Have the same problem!

swift 4 click fix it works