• 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: Newbie Question about Document/Window/Text Field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Question about Document/Window/Text Field


  • Subject: Re: Newbie Question about Document/Window/Text Field
  • From: "John C. Randolph" <email@hidden>
  • Date: Tue, 15 May 2001 02:36:47 -0700

On Tuesday, May 15, 2001, at 02:23 AM, Keith Bauer wrote:

Please excuse the newbie question...

I am trying to create a simple text-editor in my quest to learn Cocoa, so I've created a project with the document-based app template and added a big scrolling text field to the window. Bingo! I have a working text editor. Gotta love that ;)

Now I want to implement saving, so my question is: how do I get the text that's in the text view when I get asked to save my document?

Look at "TextEdit" in /Developer/Examples/AppKit/TextEdit. The code you want is in Document.m, in the method

- (void)saveDocument:(BOOL)showSavePanel rememberName:(BOOL)rememberNewNameAndSuch shouldClose:(BOOL)shouldClose whenDone:(SEL)callback

..which is rather more elaborate than you need, but it is a working example.

To do it much more simply, ask the textField for its textContainer, ask the textContainer for its string, run the save panel and use the path you get from the save panel to tell the string where to write itself out in -saveToFile:atomically:

-jcr


For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken


References: 
 >Newbie Question about Document/Window/Text Field (From: Keith Bauer <email@hidden>)

  • Prev by Date: Re: Fastest/smallest search+replace
  • Next by Date: Type/Creator Codes
  • Previous by thread: Newbie Question about Document/Window/Text Field
  • Next by thread: Fwd: Re: Newbie Question about Document/Window/Text Field
  • Index(es):
    • Date
    • Thread