replace "range.location + range.length" with NSMaxRange.