Thanks Shane. Once more to the rescue!
As the text i wanted to remove could exists in multiple places in the Client list, I used the range to remove and replace the 2nd last line, perfect.
Now, I need to identify and remove the 2nd to 9th lines in a variable list as well as the total count of lines/paragraphs.
I've tried
set textStorage to textView's textStorage() -- append new text set newTextLength to textStorage's |length|() as integer say 6 set theRange to textstorage's replaceOccurrencesOfString_withString_options_range_(linefeed,linefeed,0,{0,newTextLength-1}) #backwardsSearch say theRange
to try and get the count of linefeeds, but it doesn't work. Any ideas please anyone?
I need a rolling list of the last X client details (there's 8 lines of info for each client)
Regards
Santa
On 15/12/2012, at 9:50 PM, Shane Stanley < email@hidden> wrote: On 15/12/2012, at 7:11 PM, Brian Christmas < email@hidden> wrote: I need to remove and replace the second last line in the field if the mail processes ok, but cant work out how to do it. I can insert the appropriate text ok, but the removal has me stumped.
The line to remove is "If this remains visible, then this job did not process correctly."
To delete some text, you need to know its range. So the easiest way is probably to get the contents of the text view as an NSString, and ask it for the range of the target using, then delete that range:
set allText to textView's |string|() -- gets the full contents as an NSString set theRange to allText's rangeOfString_("If this remains visible, then this job did not process correctly." & linefeed) tell textStorage to deleteCharactersInRange_(theRange)
If you instead want to replace the text, use:
tell textStorage to replaceCharactersInRange_withString_(theRange, "Whatever" & linefeed)
tell current application's NSColorList to set AppleColors to colorListNamed_("Apple") set someColor to AppleColors's colorWithKey_("Black")
For basic colors there are dedicated class methods, like this:
set someColor to current application's NSColor's blackColor()
|