objective c compare range intersect

前端 未结 2 572
迷失自我
迷失自我 2021-02-04 11:34

I am trying to find the intersection of 2 number ranges, say for example...

range A is from 10 to 100, range B is from 60 to 70

Is there an easy way without writ

2条回答
  •  庸人自扰
    2021-02-04 12:04

    You can use this method for that purpose:

    NSRange NSIntersectionRange (
       NSRange range1,
       NSRange range2
    );
    

    You can find all the info here:

    NSIntersectionRange Apple Doc

提交回复
热议问题