Re: Setting the Line Height/ Line Spacing in an NSTextView.
Re: Setting the Line Height/ Line Spacing in an NSTextView.
- Subject: Re: Setting the Line Height/ Line Spacing in an NSTextView.
- From: Joshua Garnham <email@hidden>
- Date: Fri, 1 Jan 2010 12:35:59 +0000 (GMT)
Oh, I see. That works partly. The text that is already in the NSTextView at launch has the new Line Height but as soon as you start to type the line your typing on resets it's line height to default.
________________________________
From: Graham Cox <email@hidden>
To: Joshua Garnham <email@hidden>
Cc: email@hidden
Sent: Fri, 1 January, 2010 9:16:36
Subject: Re: Setting the Line Height/ Line Spacing in an NSTextView.
On 01/01/2010, at 7:10 PM, Joshua Garnham wrote:
> That was a spelling mistake, it was meant to say NSMutableParagraphStyle.
> I've tried doing this …
>
> CGFloat spacing = 5.0f;
> NSMutableParagraphStyle *paragraphStyle;
> [paragraphStyle init];
Well, this is just not how you allocate objects. In fact, you haven't allocated an object - you are calling -init on a piece of random memory. Usually that will crash but in this case it just so happens that the variable, by pure chance, happens to point to memory that contains a NSSortDescriptor which is rejecting the -setLineSpacing method call.
You need to do this:
NSMutableParagraphStyle* ps = [[NSMutableParagraphStyle alloc] init];
This is Cocoa 101. If you don't know about this, go back and make sure you read the most fundamental documentation. You won't get far without knowing how to correctly alloc/init objects, so fiddling with paragraph styles before you can alloc/init is definitely a case of running before you can walk.
--Graham
_______________________________________________
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