• 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: Parsing a text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing a text


  • Subject: Re: Parsing a text
  • From: Greg Herlihy <email@hidden>
  • Date: Tue, 21 Feb 2006 19:15:58 -0800
  • Thread-topic: Parsing a text

Try changing the line:

    while (index < colorRange.length){

to:

    while (index < [aText length]){

colorRange.length equals [aText length] only the first time through the
loop; afterwards colorRange stores the length of the current color text run.

So either index will have to be compared with [aText length] directly or
with some dedicated variable that caches aText's length.

Greg


On 2/21/06 9:44 AM, "Andrea Salomoni" <email@hidden> wrote:

> dear list,
>
> I'm findind some problems using attributesAtIndex:effectiveRange method.
> I have a NSMutableAttributedString declared as follow:
>
> NSRange colorRange;
> colorRange.location = 0;
> colorRange.length = [aText length];
> float index = 0;
>
> while (index < colorRange.length){
> NSDictionary * attributes = [aText attributesAtIndex:index
> effectiveRange:&colorRange];
>
> NSColor *color ;
> NSColor *rgbColor ;
> float r, g, b, a ;
>
> color = [attributes valueForKey:@"NSColor"] ;
> rgbColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] ;
> if( rgbColor != nil ) {
> [rgbColor getRed:&r green:&g blue:&b alpha:&a] ;
> NSString * theWebColor = [NSString stringWithFormat: @"%X%X%X",
> (unsigned)(r*255),
> (unsigned)(g*255), (unsigned)(b*255)];
...


 _______________________________________________
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

References: 
 >Parsing a text (From: Andrea Salomoni <email@hidden>)

  • Prev by Date: Getting one of those modal sheets that "emerges from a slit"
  • Next by Date: Re: Getting one of those modal sheets that "emerges from a slit"
  • Previous by thread: Parsing a text
  • Next by thread: Round Rect FLAT on Intel
  • Index(es):
    • Date
    • Thread