[英]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.