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.

vpqyrkdqqt
2,284 PointsWhy I am getting this error in Swift: expected ',' separator when I use #selector like in the video?
My code is identical to the one in the video but I keep getting an error message. Here is my code:
if let firstChoice = page.firstChoice {
firstChoiceButton.setTitle(firstChoice.title, forState: .Normal)
firstChoiceButton.addTarget(self, action: #selector(PageController.loadFirstChoice), forControlEvents: .TouchUpInside)
} else {
firstChoiceButton.setTitle("Play Again", forState: .Normal)
}
if let secondChoice = page.secondChoice {
secondChoiceButton.setTitle(secondChoice.title, forState: .Normal)
}
}
}
Swift does not like the #selector(). I can't figure out what the problem here is. Perhaps could it be that my version of Xcode isn't up to date? Thanks!
3 Answers

Nathan Wong
7,129 PointsIt's definitely possible that your version of Xcode isn't up to date! The new #selector
syntax will only work in Xcode 7.3 (or newer). Which are you using?

Caleb Kleveter
Treehouse Moderator 37,862 PointsI tried to update and ran into this issue:
So I used this instead:
Selector("PageController.loadFirstChoice")

Comb Giss
589 PointsIts just Selector("loadFirstChoice")

vpqyrkdqqt
2,284 PointsAwesome, that was the culprit. I updated Xcode and now everything works. Thanks again Nathan! For other Treehouse users, it does take a good amount of time to update Xcode so please be sure to set aside some time to do so.