• 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: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo


  • Subject: Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo
  • From: Dave <email@hidden>
  • Date: Mon, 25 Apr 2016 16:34:52 +0100

Hi Bill,

I’m familiar with NSAttributedString and friends. I had thought that there was a higher level interface to it as it seems like a common thing to want to do.

Basically my ScrollView is just a scrolling line log similar to XCode’s NSLog window. I’m just appending an NSString to the Document View like this:

myTextView = [self documentView];
[[[myTextView textStorage] mutableString] appendString:theString];

Should I convert “theString” to a NSAttributedString and then set the attributes of this string, or set the attributes of  [[[myTextView textStorage] mutableString] ? The reason I ask is because the TextView can get large and I’m not sure if setting the attributes each time would slow things down?

Thanks a lot,
All the Best
Dave



> On 25 Apr 2016, at 12:28, Bill Cheeseman <email@hidden> wrote:
>
>
>> On Apr 25, 2016, at 6:48 AM, Dave <email@hidden> wrote:
>>
>> I can’t believe its this hard to set wrapping or not and I can’t find real info on this from searching either.
>
> For your purposes, the key point is that NSTextStorage is a subclass of NSMutableAttributedString, which is in turn a subclass of NSAttributedString. You should be looking at methods like NSMutableAttributedString's -setAttributes:range:. Basically, you start by creating a dictionary of formatting attributes, then you provide it to -setAttributes:range: with the range of characters to which you want those attributes applied. That's why they're called "attributed" strings -- they are strings with formatting attributes.
>
> Look at the introduction to the NSAttributedString technical reference document, the NSAttributedString AppKit Additions reference document, Text Attribute Programming Topics, and the Attributed String Programming Guide. The "Paragraph Attributes" section of the Text Attribute Programming Topics is especially pertinent to your question, including its cross reference to the much more detailed Ruler and Paragraph Style Programming Topics.
>
> --
>
> Bill Cheeseman - email@hidden
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo
      • From: Dave <email@hidden>
References: 
 >How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo (From: Dave <email@hidden>)
 >Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo (From: Andreas Mayer <email@hidden>)
 >Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo (From: Dave <email@hidden>)
 >Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo (From: Bill Cheeseman <email@hidden>)
 >Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo (From: Dave <email@hidden>)
 >Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo (From: Bill Cheeseman <email@hidden>)
 >Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo (From: Dave <email@hidden>)
 >Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo
  • Next by Date: Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo
  • Previous by thread: Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo
  • Next by thread: Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo
  • Index(es):
    • Date
    • Thread