Re: Newbie:Attributed Text Strings and NSTextView
Re: Newbie:Attributed Text Strings and NSTextView
- Subject: Re: Newbie:Attributed Text Strings and NSTextView
- From: Tony Cate <email@hidden>
- Date: Sat, 25 Sep 2004 06:50:31 -0500
Both varients of addAttribute requite a range:
- (void)addAttributes:(NSDictionary *)attributes range:(NSRange)aRange
- (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)aRange
I find AppKiDo invaluable for this kind of thing.
I assume testList is a textView. Try: [[textList textStorage] setAttributedString:stringTest].
Tony
3 Cats And A Mac
http://www.3caam.com
>I have a program with two NSTextViews. The first NSTextView holds a
>simple NSString. This one works great. The second NSTextView holds an
>attributed string (or at least it should) that changes the display
>font. Two problems have happened. I initialize the NSAttributedString
>with the NSString used to fill the first NSTextView. Then I use the
>NSFont class to create a font object I attempt to use a font with the
>name Arial. Obviously I have constructed this call wrong since it
>fails to compile. Next when I attempt to use the addAttribute I am
>told that stringTest will not respond to the addAttribute method. Last
>I have failed to find the method to set the contents of the testList
>NSTextView to the testString. Source code shown below.
>
>Thanks
> newFont = [fontWithName:@"Arial" size:24];
> stringTest = [[NSMutableAttributedString alloc]
>initWithString:stringNumber];
> [stringTest addAttribute:NSFontAttributeName
> value:[newFont userFontSize:24]];
> [testList setString:stringTest];
>-----
> _______________________________________________
>Do not post admin requests to the list. They will be ignored.
>Cocoa-dev mailing list (email@hidden)
>Help/Unsubscribe/Update your Subscription:
>
>This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden