Hi, I keyed Listing 18.10 and other listings into Xcode, and configured Main.storyboard as instructed by the book, but when I ran the project in the simulator and tapped on those emoji images at the bottom of the screen, the addMood button didn’t have any changed.
I put a print(“button tapped”) statement in the @IBAction private fun moodSelectionChanged(_ sender: ImageSelector) method and ran the project again. When I tapped on any of those emoji images, nothing was printed in the console. That shows the moodSelectionChanged(_ sender: ImageSelector) method was not called when any of the emoji images (buttons) was tapped.
The logic here in the listing code leaves me wondering what the real sender is. Apparently, it should be the UIButtons instead of the ImageSelector. When I tap on one of the images, the code should respond to my tap. In this process, the underlying image selector view does receive any changes. That’s why the moodSelectionChanged(_ sender: ImageSelector) method doesn’t get called in response.
So, I wonder whether there is anything wrong with the code here.