if case 1 : range1 is (5,10) and range2 is (8,0) it should return true. case 2 : range1 is (5,10) and range2 is (5,4) it should return true. case 3 if range1 is (5,10) and range2 is (14,20) it should return true. How to implement a function that return true for all cases. I want to check if a range intersect with another range or completely within it.
Range (the Swift way) has a method overlaps. If you want to work with NSRange it would be:
NSIntersectionRange(range1, range2).length > 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With