Error:

Create range

// Result is with beginning at 2 and length equal 5
NSRange r = NSMakeRange(2, 5);

Convert the range to string

NSRange r = NSMakeRange(2, 5);
// Result is "{2, 5}"
NSString *rangeStr = NSStringFromRange(r);

Get intersection of two ranges

NSRange range1 = NSMakeRange(2, 5);
NSRange range2 = NSMakeRange(3, 10);
// i.location = 3, i.length = 4
NSRange i = NSIntersectionRange(range1, range2)));

Check if location is in the range

NSRange range = NSMakeRange(2, 5);
// Result is YES
BOOL isIn = NSLocationInRange(6, range);

Get top end of the range

NSRange range = NSMakeRange(2, 5);
// Result is 7
NSUInteger end = NSMaxRange(range);

Get union of two ranges

NSRange range1 = NSMakeRange(2, 5);
NSRange range2 = NSMakeRange(10, 10);
// u.location = 2, u.length = 18
NSRange u = NSIntersectionRange(range1, range2)));

Parse range from the string

NSRange range = NSRangeFromString(@"{2, 2}");