setNeedsDisplay is meant to ask the system to call drawRect:, and there are great answers on StackOverflow like this. But an example may be helpful.

Code in drawRect: just draw a line between two points.

With setNeedsDisplay, the effect is

image

Without setNeedsDisplay, the effect is

image