Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

varsis

macrumors regular
Original poster
Nov 30, 2005
209
1
Here is what I am trying to do,

I retrieve two NSRanges one which comes from a document and one that is in the application I want to know if the Ranges are overlapping in anyway if they are. Also get the portion of the overlapping range.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
NSRange is just a C struct as described in this document. You can simply retrieve the location and length from each range and work out if they overlap.

There is also the very handy NSIntersectionRange function which will return a new range representing the intersection (or overlap). This basically does exactly what you want.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.