Try this, it inserts 4 spaces at the beginning of the first line of the textView (not in the first line of each paragraph, I'm not sure what you wanted?)
textView.text = [textView.text stringByReplacingCharactersInRange:NSMakeRange(0,0) withString:@" "];
To prevent the user from indenting the selection point:
Set a textview delegate and make a textViewDidChangeSelection:method
Then in the method do something like:
if (textView.selectedRange.location < 4) {
textView.selectedRange = NSMakeRange(4, 0)
}
source
share