G'day Scripters
I thought from Shane Stanleys advice that I'd be able to solve any problems that came my way, but I've tried on and off for the past five days to get this working, to no avail. I've followed Shanes example to the letter as far as I can tell, but constantly get a ' -[NSCachedRGBColorString]: unrecognised selector sent to' error.
I've looked at the low number of hits on the net re. the error message that really don't tell me anything, so am at a loss as to why my method is not working. I've tried with a range, and with missing value, which according to the log, should work.
Any advice appreciated, please.
Regards
Santa
set tempParagraphString to paragraph (paragraphCounter as integer) of mainMessagesStringText as text
set p to 11
set theParagraphLength to (count of tempParagraphString) + 1 as integer
set p to 12
#
# Check for blank line first.
#
say theParagraphLength as text
if theParagraphLength as integer ≠ 0 as integer then
set theStartOfPlainTextParagraph to (theEndOfPlainTextParagraph + 1) as integer
set p to 13
set theEndOfPlainTextParagraph to (theStartOfPlainTextParagraph + theParagraphLength) as integer
say theStartOfPlainTextParagraph as text # <= zero
set p to 14
#
set mainMessagesAttributableText to mainMessagesView's textStorage()
#
# Grab the color value of each single start-of-paragraph item.
#
# The variable mainMessagesAttributableText is 302 characters in length and
# starts at zero.
#
# This should be just 'theStartOfPlainTextParagraph as integer', as
# theStartOfPlainTextParagraph is zero on first pass, but I've added
# the '+ 1' to make <sure> I'm referring to an existing item Attribute.
#
# THIS fails...
#
set checkItemColor to mainMessagesAttributableText's attribute_atIndex_effectiveRange_(current application's NSForegroundColorAttributeName, (theStartOfPlainTextParagraph + 1) as integer, {(theStartOfPlainTextParagraph + 1) as integer, 1 as integer})
#
# SO does this…
#
set checkItemColor to mainMessagesAttributableText's attribute_atIndex_effectiveRange_(current application's NSForegroundColorAttributeName, (theStartOfPlainTextParagraph + 1) as integer, missing value)
From the log…
-[NSConcreteTextStorage attribute:atIndex:effectiveRange:]: value passed to argument of type ^{_NSRange=QQ} must be either `missing value' or `reference'; assuming `missing value'.
2014-10-01 09:51:14.699 ApplescriptObjC Wizard[18745:303] -[NSCachedRGBColor string]: unrecognized selector sent to instance 0x100166d60
On 25/09/2014, at 10:03 PM, Shane Stanley <
email@hidden> wrote:
Well you have the attributed string. You can either get the attributes of it as a dictionary, using one of the attributesAtIndex:: methods, or just use:
attribute_atIndex_effectiveRange_(current application's NSForegroundColorAttributeName, theIndex, missing value) if that's the only attribute you're interested in.