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 <graham....@bigpond.com>
To: Joshua Garnham <joshua.garn...@yahoo.co.uk>
Cc: cocoa-dev@lists.apple.com
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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to