I’m parsing a SVG file to UIBezierPath. I’d like to know whether a CGPoint is inside or outside the UIBezierPath. To do this I use containsPoint:. When I run this in the simulator everthing works fine (almost!). When I run it a iPad device it crashes on some paths and points. I’m calling closePath on every UIBezierPath before I call containsPoint:.
Here are some paths and points, which makes it crash (I randomize the points, so there might be more crash points):
Crash Points: (659.0, 444.0), (659.0, 443.0)
SVG Path: M661 446 c1 -1 3 -1 4 -1 1 -1 2 -2 2 -4 0 -2 0 -2 -2 -2 0 1 -2 1 -3 1 -2 0 -3 1 -3 2 0 1 0 2 0 3 0 0 1 1 2 1z
Crash Points: (533.0, 458.0), (533.0, 457.0)
SVG Path: M535 460 c0 0 1 -1 1 -2 1 -2 0 -3 -1 -3 0 0 -1 0 -2 1 0 1 0 2 0 3 1 0 1 1 2 1z
I can’t figure out why it crashes. To me it should return YES or NO no matter what path or point it gets.
Why does it crash? 🙁
It turns out the crash is a bug in the framework. This answer provides another way to determine whether a point is inside a
UIBezierPath.