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

Parsing a text


  • Subject: Parsing a text
  • From: Andrea Salomoni <email@hidden>
  • Date: Tue, 21 Feb 2006 18:44:43 +0100

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)];


[aText replaceCharactersInRange:colorRange withString:FONT_COLOR];
index+= colorRange.length+1;
}
else {
[self returnError:0];
}
}
//
But the only words parsed is always the first....
Where I'm wrong?
Thank you for your kind support
Andrea


_______________________________________________
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: Parsing a text
      • From: Greg Herlihy <email@hidden>
  • Prev by Date: Re: (FSResolveAlias, mount_smbfs) Set timeout in case network volume is unreachable?
  • Next by Date: Round Rect FLAT on Intel
  • Previous by thread: Re: (FSResolveAlias, mount_smbfs) Set timeout in case network volume is unreachable?
  • Next by thread: Re: Parsing a text
  • Index(es):
    • Date
    • Thread