• 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
Storing NSString with attributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Storing NSString with attributes


  • Subject: Storing NSString with attributes
  • From: Ivan Myrvold <email@hidden>
  • Date: Sun, 2 Dec 2001 19:50:08 +0300

My application have two NSTextView which a user can edit texts, and an NSOutlineView in a drawer where the user can click on a line, and the contents of the two NSTextView's will change accordingly.

This works very well with basic text, I am using the "string" and "setString" methods to get and set the text in the two views.
But I thought I would add the possibility to set some text attributes, like bold and italic etc.

It was very easy to add the font menu in IB to the application, and the thing worked also...until I changed to a new line in the outline view.

That is probably because I use the "string" method to extract the text from the NSTextView, and even if I have selected some text to be bold, the string method is stripped of any such attributes.

So which method should I use to extract the text from my views? I have read the NSText, NSAttributedString, NSTextStorage documents without quite understanding how to do this.

Ivan


  • Follow-Ups:
    • Re: Storing NSString with attributes
      • From: "Clark S. Cox III" <email@hidden>
  • Prev by Date: Re: NSUserDefaults and the synchronize: method - doesn't seem to sync...
  • Next by Date: Re: representing TABs in NSString.
  • Previous by thread: Re: NSUserDefaults and the synchronize: method - doesn't seem to sync...
  • Next by thread: Re: Storing NSString with attributes
  • Index(es):
    • Date
    • Thread