The previous answer didn't work for me, the compiler complains:
Sending 'void *' to parameter of incompatible type 'NSRange' (aka 'struct _NSRange')
I had to use an empty NSRange
struct instead:
[self setSelectedRange:(NSRange){ .location = 0, .length = 0 }];