• 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: Martin Wierschin <email@hidden>
  • Date: Wed, 27 Apr 2016 01:01:55 -0700

This code is never going to work:

> [[myTextView textStorage] addAttribute:NSParagraphStyleAttributeName value:[NSNumber numberWithInt:NSLineBreakByTruncatingTail] range:myRange];
>
> But this results in nothing being displayed in the ScrollView/TextView.

In fact, using that code probably threw at least one exception, which is why you're not seeing anything in your text view.

The NSParagraphStyleAttributeName attribute expects a NSParagraphStyle object as its value, not an NSNumber. The value you're trying to set (the line breaking mode) is a property of the paragraph style. You want code that resembles:

	NSMutableParagraphStyle* paraStyle = [[NSMutableParagraphStyle alloc] init];
	[paraStyle setLineBreakMode:NSLineBreakByTruncatingTail];
	[textStorage addAttribute:NSParagraphStyleAttributeName value:paraStyle range:myRange];

That's typed into Mail and may have errors, but you get the idea.

~Martin Wierschin

_______________________________________________

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>)
 >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: Dave <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