adamwulf / ClippingBezier

ClippingBezier calculates intersection points, paths, and shapes between two UIBezierPaths
http://getlooseleaf.com/opensource/
MIT License
256 stars 34 forks source link

"index 3 beyond bounds" exception #7

Open AndrewHartAR opened 5 years ago

AndrewHartAR commented 5 years ago

I've attached the entire project - upon running it you should run into a crash with the error:

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 2]'

It points to this line in UIBezierPath+Clipping:

    void (^fixSegmentIntersections)(NSArray*, NSMutableArray*) = ^(NSArray* segmentsToFix, NSMutableArray* output) {
        for(DKUIBezierPathClippedSegment* seg in segmentsToFix){
            NSUInteger indx;
            DKUIBezierPathIntersectionPoint* correctedStartIntersection = seg.startIntersection;
            indx = [allSubpathToShapeIntersections indexOfObject:seg.startIntersection];
            if(indx != NSNotFound){
                // we found an intersection in the full scissor path that we can map to,
                // so use that for the start
                correctedStartIntersection = [scissorToShapeIntersections objectAtIndex:indx];

Project attached. Other than that, congrats on the great work.

beziertest.zip