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: Graham Cox <email@hidden>
- Date: Fri, 1 Jan 2010 20:16:36 +1100
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