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: Dave <email@hidden>
- Date: Wed, 27 Apr 2016 10:41:44 +0100
> On 27 Apr 2016, at 09:01, Martin Wierschin <email@hidden> wrote:
>
> 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
>
Yes, it was throwing but I didn’t notice it because of problem I’ve got with the Debugger catching exception breakpoints.
Cheers
Dave
_______________________________________________
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