Question

I'd like to get the substring of an NSAttributedString that has a certain attribute. How do I do this?

Thanks!

Was it helpful?

Solution

I'm not sure but according to the documentation, you should be able to call -enumerateAttribute:inRange:options:usingBlock: and the specify the attribute you seek as the first and the range of the string you want to search through as the second argument. The ranges where the specified attribute is present are supplied to the block you pass to the method.

OTHER TIPS

The non-block-based version of what Ole suggested is the attribute:atIndex:effectiveRange: method (or its sibling), which you call repeatedly, advancing the index, until you run out of string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top