• 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: Izidor Jerebic <email@hidden>
  • Date: Tue, 21 Feb 2006 11:28:17 +0100


On 21.2.2006, at 10:59, Andrea Salomoni wrote:

Hi to all,

I already find the way to parse correctly the attributed string, and I can read the dictionary with NSColor key....
But the problem is the following:


My function returns me this line string: NSCalibratedRGBColorSpace 0.531465 1 0.821694 1

This is the output when logged to console, but the value in dictionary is in fact NSColor object. What you see above is the description of this object.


I need only the rgb value to convert it a a websafe color (or an html version of this color)....
I cannot use the method [myAttributesDictionary valueForKey:@"NSColor"]; because the string is filled with not only the rgb values....

This code snippet should get you RedGreenBlue components in float variables or error message if this is some incompatible color:


NSColor *color ;
NSColor *rgbColor ;
float r, g, b, a ;

color = [myAttributesDictionary valueForKey:@"NSColor"] ;
rgbColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] ;
if( rgbColor != nil ) {
  [rgbColor getRed:&r green:&g blue:&b alpha:&a] ;
}
else {
  NSLog( @"Can't get RGB components out of %@", color ) ;
}


izidor

_______________________________________________
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: 
 >Re: Find color's change in a NSString (attributed) (From: Andrea Salomoni <email@hidden>)

  • Prev by Date: Re: Core Data: updating a key dependent on a to-many relationship?
  • Next by Date: Re: Growl Support?
  • Previous by thread: Re: Find color's change in a NSString (attributed)
  • Next by thread: Re: Find color's change in a NSString (attributed)
  • Index(es):
    • Date
    • Thread