Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use NSRange [duplicate]

I am using NSRange with an Attributed string, but I don't fully understand which parts of the text will be bolded and which are not. This is what I tried:

NSRange boldedRange = NSMakeRange(2, 4);

What exactly does the 2 stand for and the 4 stand for?

Thanks in advance for anyone who contributes to this post

like image 757
Ameya Vaidya Avatar asked Dec 29 '15 17:12

Ameya Vaidya


1 Answers

It says as:

NSMakeRange(<#NSUInteger loc#>, <#NSUInteger len#>)

So in your case:

NSRange boldedRange = NSMakeRange(2, 4);

2 is the starting location.

4 is the character count till what it will use.

Ex. If you use boldedRange on TYPEWRITER, it will change it to TYPEWRITER

like image 103
Anoop Vaidya Avatar answered Oct 09 '22 02:10

Anoop Vaidya