• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: COCOA: Simplest Way of Formatted Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: COCOA: Simplest Way of Formatted Text


  • Subject: Re: COCOA: Simplest Way of Formatted Text
  • From: Nebagakid <email@hidden>
  • Date: Tue, 21 Jan 2003 16:35:02 -0500

What I am looking for, for example, is a way to take the entire contents of an NSTextView (with different colors, fonts, even pictures) and be able to put that into one string with just saying "I want this variable to be equal to the Rich Text of this Text View" .... Am I talking crazy here (I am really new at Cocoa) ?

-Danny Cohen
On Tuesday, January 21, 2003, at 01:20 PM, Douglas Davidson wrote:


On Tuesday, January 21, 2003, at 04:46 AM, Nebagakid wrote:

Let's say I wanted to set this nice Text-View to some Rich Text with different colors, fonts, and some text in the center, some on the left (Second day on the job here with Cocoa).. how can I do all this in one string that could be moved around easily? Like, there would be text on screen, and all that would be necessary is for the Program to get the Text and keep the formatting.

I'm not sure I understand what you are after, but the basic styled text object in Cocoa is the attributed string. See the documentation for the classes NSAttributedString and NSMutableAttributedString for more information. This is complicated a bit by the fact that NSAttributedString itself is defined in Foundation, but most of the interesting attributes (font, color, etc.) are defined in the AppKit, so there is a separate NSAttributedString.h header in the AppKit that you will want to look at as well.

When you are dealing with a text view, you should remember that the underlying text is stored in an NSTextStorage. This is a subclass of NSMutableAttributedString, with the additional behavior of notifying its associated objects (via NSLayoutManager) when it changes.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: COCOA: Simplest Way of Formatted Text
      • From: j o a r <email@hidden>
    • Re: COCOA: Simplest Way of Formatted Text
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: COCOA: Simplest Way of Formatted Text (From: Douglas Davidson <email@hidden>)

  • Prev by Date: creating an input manager
  • Next by Date: Re: COCOA: Simplest Way of Formatted Text
  • Previous by thread: Re: COCOA: Simplest Way of Formatted Text
  • Next by thread: Re: COCOA: Simplest Way of Formatted Text
  • Index(es):
    • Date
    • Thread