Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Alex Busu
PLUS
Alex Busu
Courses Plus 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

i just clicked "Fix" and it worked.

I Have the same problem!

swift 4 click fix it works