Query on the NSTextCheckingResult.resultByAdjustingRangesWithOffset output.

Hello

I am running a sample program on OSx to adjust the Ranges within an NSTextCheckingResult object using the api .resultByAdjustingRangesWithOffset(). Below is the output when I give the offset as '922337203685477580' . See Output 1: I see that the location field of the range is modified to a negative (signed) integer when it goes beyond Int.max. Wondering if this is deliberately done and working as expected OR this should fail as an invalid argument exception (similar to the case seen when the offset passed causes the modified location to go less than 0 ie. negative. See Output 2: )

Output 1:

ยทยทยท

Ranges:

(5, 2)

(9223372036854775807, 0)

(5, 1)

Calling: .resultByAdjustingRangesWithOffset(9223372036854775807)

Adjusted ranges:

(-9223372036854775804, 2)

(9223372036854775807, 2)

(-9223372036854775804, 2)


Output 2:


Ranges:

(5, 2)

(9223372036854775807, 0)

(5, 1)

Calling: .resultByAdjustingRangesWithOffset(-6)

Adjusted ranges:

2016-06-06 15:55:44.358 TestProject[5628:211197] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSSimpleRegularExpressionCheckingResult resultByAdjustingRangesWithOffset:]: -6 invalid offset for range {5, 2}'

*** First throw call stack:

:

:


Any help on understanding the expected output is appreciated.

Thank you.

Regards

Mamatha