Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo
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