简体   繁体   English

如何确定NSInteger在NSRange中?

[英]How to determine a NSInteger is in the NSRange?

For example,a NSInteger 8 ,is in the NSRange (4,10). 例如, NSInteger 8位于NSRange (4,10)中。 I have checked NSRange API and didn't find one method to determine it. 我检查了NSRange API,没有找到一种确定它的方法。

Use NSLocationInRange : 使用NSLocationInRange

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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