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 Touch Events

Hayden Pennington
Hayden Pennington
6,154 Points


Is the call to 'setNeedsDisplay()' actually beneficial in this code? If so, can someone please explain why?

I removed the call to 'setNeedsDisplay' from the touchesBegan method. Now, drawRect is only called once. However, the app still functions as expected.

I can understand wanting drawRect to be called if we wanted to change attributes of the crosshair, but in this case we're only changing the position.

Hopefully someone can shine some light on this for me. Thanks!

  • Hayden