• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Find color's change in a NSString (attributed)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find color's change in a NSString (attributed)


  • Subject: Re: Find color's change in a NSString (attributed)
  • From: Stephane Sudre <email@hidden>
  • Date: Mon, 20 Feb 2006 17:36:37 +0100


On 20 févr. 06, at 17:18, Andrea Salomoni wrote:

Hi to all,

I have a text with some colors and I need to parse the text and know the words with the color and change it.
I already parsed the text succesfully , but cannot find any documentation about searching the color's change in a text.
Anyone can help me?

Hmm, maybe this can work:

tIndex=0;

tLength=[tAttributedString length];

while (tIndex<tLength)
{
tRangeLimit=NSMakeRange(tIndex,tLength-tIndex);

tAttributes=[tAttributedString attributesAtIndex:tIndex longestEffectiveRange:&tRangeOut inRange:tRangeLimit];


	if (tAttributes!=nil)
	{
		NSColor * tForeColor;

		tForeColor=[tAttributes objectForKey:NSForegroundColorAttributeName];

if ([tForeColor isClosedTo:myColor]==YES) // isClosedTo is a method I use in a category of NSColor
{
// Do my stuff
}


		tIndex+=tRangeOut.length;
	}
	else
	{
		break;
	}
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Find color's change in a NSString (attributed)
      • From: Andrea Salomoni <email@hidden>
References: 
 >Find color's change in a NSString (attributed) (From: Andrea Salomoni <email@hidden>)

  • Prev by Date: Find color's change in a NSString (attributed)
  • Next by Date: Re: Find color's change in a NSString (attributed)
  • Previous by thread: Find color's change in a NSString (attributed)
  • Next by thread: Re: Find color's change in a NSString (attributed)
  • Index(es):
    • Date
    • Thread