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 Personalizing the Story Modifying Constraints

Qasa Lee
Qasa Lee
18,916 Points

How to understand "func keyboardWillShow(_ notification: Notification)" be called in the selector without parameter?

I know in the #selector() we just have to pass in the name of the method we're calling, but how can keyboardWillShow(_ notification: Notification) know the notification without giving any clue? NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillShow), name: Notification.Name.UIKeyboardWillShow, object: nil) the code above can send the exact notification to the function keyboardWillShow()?! Or just because the #selector(self.keyboardWillShow) can grab the notification since it knows this comes from UIKeyboardWillShow ?!