Reputation: 1227
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.
Upvotes: 4
Views: 3256
Reputation: 1350
Range (the Swift way) has a method overlaps. If you want to work with NSRange it would be:
NSIntersectionRange(range1, range2).length > 0
Upvotes: 11