Hey @crvillanueva thanks for your question! :]
There are two reasons that the state pattern is useful here:
Yes, it’s a convenient way to fix the “bug” of allowing the user to draw while the app is animating.
DrawView is doing way too much - the code is very complex already. If this were a real, large app, you’d likely struggle to both maintain and understand this class as you continued to add code to it over time.
In itself, reason 2 is definitely enough to justify this change. However, reason 1 is important too… you can imagine that this is a critical “shouldn’t be allowed” blocker issue, for example.
I just tested on the iPhone 8 simulator, and the final app works as expected. However, something has changed with the iPhone X/XR simulator, and this doesn’t actually prevent you from drawing while animating…! It also seems the drawing performance in the simulator is terrible…
I’m not sure if this is a simulator bug, or if it will behave correctly on a real iPhone X/XR or not… I don’t have a real device to test using right now. However, I’m going to look into the issue further, and see if I can get it fixed in a future version of the book.
Thanks you bringing this issue up! Let me know if you have any other questions about this or anything else. :]