Getting error in - (BNRLine *)lineAtPoint:(CGPoint)p


#1

I’m getting a few errors in the ‘Multiple Gesture Recognizers’ portion of the code. Can someone help me?

  • (BNRLine *)lineAtPoint:(CGPoint)p
    {
    // Find a line close to p
    for (BNRLine *1 in self.finishedLines) { [color=#FF0000]! Expected identifier or ‘(’[/color]
    CGPoint start = 1.begin;
    CGPoint end = 1.end;

      // Chek a few points on the line
      for (float t = 0.0; t <= 1.0; t += 0.05) {
          float x = start.x + t * (end.x - start.x);
          float y = start.y + t * (end.y - start.y);
          
          // If the tapped point is within 20 points, let's return this line
          if (hypot(x - p.x, y - p.y) < 20.0) {
              return 1;
          }
      }
    

    }

    // If nothing is close enough to the tapped point, then we did not select a line
    return nil; [color=#FF0000]! Expected ‘;’ in ‘for’ statement specifier[/color]
    } [color=#FF0000]! Expected ‘)’[/color]


#2

[quote]- (BNRLine *)lineAtPoint:(CGPoint)p
{
// Find a line close to p
for (BNRLine *[color=#FF0000]1[/color] in self.finishedLines) { ! Expected identifier or '('
CGPoint start = [color=#FF0000]1[/color].begin;
CGPoint end = [color=#FF0000]1[/color].end;

[/quote]
Replace those [color=#FF0000]red[/color] 1s with a valid identifier (an identifier can’t start with a digit.)


#3

[quote=“ibex10”][quote]- (BNRLine *)lineAtPoint:(CGPoint)p
{
// Find a line close to p
for (BNRLine *[color=#FF0000]1[/color] in self.finishedLines) { ! Expected identifier or '('
CGPoint start = [color=#FF0000]1[/color].begin;
CGPoint end = [color=#FF0000]1[/color].end;

[/quote]
Replace those [color=#FF0000]red[/color] 1s with a valid identifier (an identifier can’t start with a digit.)[/quote]

Wow, thank you so much for that. What an odd error to have in the book…