Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to do negative loc in the NSMakeRange?

Tags:

ios

nsrange

Is it possible to do negative loc in the NSMakeRange?

NSString *string = @"abc";
NSString *myString = [string substringWithRange:NSMakeRange(-1, 1)];
like image 535
Voloda2 Avatar asked Dec 05 '25 02:12

Voloda2


1 Answers

No.

location and length are unsigned integers :

typedef struct _NSRange {
    NSUInteger location;
    NSUInteger length;
} NSRange;

and also, NSMakeRange function is defined as follow :

NSRange NSMakeRange (
    NSUInteger loc,
    NSUInteger len
);

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!