Turning Touches into Lines

A line is defined by two points. Your BNRLine stores these points as properties named begin and end. When a touch begins, you will create a line and set both begin and end to the point where the touch began. When the touch moves, you will update end. When the touch ends, you will have your complete line.

In BNRDrawView.m, implement touchesBegan:withEvent: to create a new line.

-​ ​(​v​o​i​d​)​t​o​u​c​h​e​s​B​e​g​a​n​:​(​N​S​S​e​t​ ​*​)​t​o​u​c​h​e​s​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​w​i​t​h​E​v​e​n​t​:​(​U​I​E​v​e​n​t​ ​*​)​e​v​e​n​t​ {​ ​ ​ ​ ​U​I​T​o​u​c​h​ ​*​t​ ​=​ ​[​t​o​u​c​h​e​s​ ​a​n​y​O​b​j​e​c​t​]​;​ ​ ​ ​ ​/​/​ ​G​e​t​ ​l​o​c​a​t​i​o​n​ ​o​f​ ​t​h​e​ ​t​o​u​c​h​ ​i​n​ ​v​i​e​w​'​s​ ​c​o​o​r​d​i​n​a​t​e​ ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.