Je voudrais obtenir la sous-chaîne d'un NSAttributedString qui a un certain attribut. Comment puis-je faire cela?Récupère la sous-chaîne de la chaîne nsattributed qui a un certain attribut
Merci!
Je voudrais obtenir la sous-chaîne d'un NSAttributedString qui a un certain attribut. Comment puis-je faire cela?Récupère la sous-chaîne de la chaîne nsattributed qui a un certain attribut
Merci!
Je ne suis pas sûr mais selon la documentation, vous devriez pouvoir appeler -enumerateAttribute:inRange:options:usingBlock:
et spécifier l'attribut que vous recherchez en tant que premier et la gamme de la chaîne que vous souhaitez rechercher en tant que second argument. Les plages où l'attribut spécifié est présent sont fournies au bloc que vous transmettez à la méthode.
La version non-bloquée de ce que Ole a suggéré est the attribute:atIndex:effectiveRange:
method (ou its sibling), que vous appelez de manière répétée, en faisant avancer l'index, jusqu'à ce que vous manquiez de chaîne.