简体   繁体   中英

How to determine a NSInteger is in the NSRange?

For example,a NSInteger 8 ,is in the NSRange (4,10). I have checked NSRange API and didn't find one method to determine it.

Use NSLocationInRange :

NSInteger num = 8;
NSRange range = NSMakeRange(4, 10); // 4 - 14
if (NSLocationInRange(num, range)) {
    // num in range
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM