Parsing a text
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