I've to searching for in NSMutableAttributedString* textToAnalize;
the number of characthers with a specific attribute.
So in this code
while (index<[[self textToAnalize]length]) {
NSRange range;
id value=[self.textToAnalize attribute:attributeName atIndex:index effectiveRange:&range];
if (value) {
[text appendAttributedString:[self.textToAnalize attributedSubstringFromRange:range]];
index=range.location+range.length;
}
else index++;
there's a local variable called range and for method attribute: atIndex: effectiveRange: it is passed as argument of effectiveRange
Now I'm wondering how this range is setted automatically when this method find the attribute. I'll try to explain it better :
NSRange range
is local not initialized variable so inside it, location
and length
has 0 0
values.
Below the method there's a update of index with the value of location
and length
but nobody setted the values of those.
My teacher said that it's automatically setted by the method above but I've searched in Apple Documentation pages but I've not discovered an explanation.