The second argument of NSMakeRange
represents the length
(counted from the start index in the first argument).
So you want NSMakeRange([self length] / 2, ([self length] + 1) / 2)
.
By the way, this method of splitting strings only works correctly when there are no combined character sequences or surrogate pairs in the string.