Discussion in 'Mac Programming' started by varsis, Sep 15, 2008.

  1. varsis macrumors regular

    Nov 30, 2005
    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.
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    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.
  3. varsis thread starter macrumors regular

    Nov 30, 2005
    Thanks! Got it working...

Share This Page