use*_*548 6 integer objective-c nsrange
我有一个NSRange,需要将一个字符串分成两个子串,在这个NSRange的两侧.如何从NSRange中获取整数值(如索引)?
NSRangestruct 由两个整数组成 - thelocation和 the length。
typedef struct _NSRange {
NSUInteger location;
NSUInteger length;
} NSRange;
Run Code Online (Sandbox Code Playgroud)
它看起来像location和location+length是您正在寻找的两个表达式 - 左右子字符串的范围如下:
NSRange prefixRange = NSMakeRange(0, myRange.location);
NSUInteger pos =myRange.location+myRange.length;
NSRange suffixRange = NSMakeRange(pos, myString.length - pos);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3943 次 |
| 最近记录: |