Stop enumerateAttribute: inRange: options: usingBlock: from calling my block with null values

I call the following selector on an existing NSAttributedStringwithout ranges kCTFontAttributeName:

[attributedString enumerateAttribute:(NSString *) kCTFontAttributeName
                             inRange:NSMakeRange(0, [attributedString length])
                             options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
                          usingBlock:^(id value, NSRange range, BOOL *stop) {
    NSLog(@"Attribute: %@, %@", value, NSStringFromRange(range));
}];

and I get the output below, but I expect not to get the output. Suggestions?

Attribute: (null), {0, 27}
Attribute: (null), {27, 1}
Attribute: (null), {28, 1}
Attribute: (null), {29, 1}
Attribute: (null), {30, 1}
+4
source share
1 answer

Short answer? -enumerateAttribute:inRange:options:usingBlock:doesn’t do what you (or I, originally) thought it was.

, , . . . , . value, , . , nil value.

, , , , value nil. , ( ), , , value . , , , , value nil, value, .

, . , .

+9

Source: https://habr.com/ru/post/1782618/


All Articles