On 26 Sep 2014, at 1:59 pm, Brian Christmas <email@hidden> wrote:
I've spent all morning trying different things, without success. More damn frustration with lack of documentation.
So yesterday I posted a suggested approach to problem solving. One of the items was:
* In the documentation for the relevant class, click near the top where it says More related items.... If it points to a related programming guide, look at it -- it will probably include sample Objective-C code and tips.
If you had followed that advice, you would have found a link to 'Introduction to Attributed String Programming Guide'. You would see that it includes a section on retrieving attribute values, and you would see it has a section listing the Standard Attributes, which has a table of the identifiers or keys. And lots of other stuff besides.
With respect, it's not so much a lack of documentation as your insistence on ignoring suggestions on how to find it. It may not be great documentation, but it's under your nose. My method is below, and any guidance on how to actually read the r,g,b values from the attribute (and from an NSColor), greatly appreciated.
Attributes don't have r,g,b values.
Need help with this…
set red1 to myFontColor's valueForKey(red) # data should be saved as keys, what key name? OR, do we need different approach?
So yesterday I also suggested:
* Assuming the statment has a method call, look up the method in the docs. Double-check its spelling and case; copying and pasting can help. Double-check the underscores or colons, and that there are a matching number of parameters. Double-check that it's an instance/class method, depending on how you are calling it. Double-check that the instance or class is presented properly. Double-check the types of the parameters and the return type. Double-check that you haven't mis-typed the parameter variables. Double-check that you have used reference properly for any out parameters. Double-check that you have added the framework for the relevant class to your project. Double-check that the method does what you want.
* Don't rely on your memory.
* Do the previous checking step again. This will catch most problems.
NSColor has no valueForKey method, as you would see if you did the above. And if it did, it wouldn't take a parameter like that, because you have no underscore. Indeed, there is no such method -- it's valueForKey_. So I guess you completely ignored my advice here, too, or you would have seen why it won't work. # This is an NSColor. How do we find the r,g,b values?
My guess would be you look at NSColor for a suitable method. Did you try, for example, -redComponent? It's listed under 'Retrieving Individual Components', and the documentation says it returns "The color object's red component." And if you look a bit further, you'll see -greenComponent and -blueComponent too. Might be worth a look.
Now I have a question: Did I just waste my time typing up that checklist yesterday?
|