• 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: Best way to save this doc?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to save this doc?


  • Subject: Re: Best way to save this doc?
  • From: Andy Lee <email@hidden>
  • Date: Sat, 13 Apr 2002 14:17:07 -0400

At 12:21 PM -0400 4/13/02, Marc Respass wrote:
I've added a "note" to a deck. The note is an NSTextView and I want to use rich text. I changed the deck to use NSData as the note instead of an NSString. I'm still saving using encodeWithCoder and it looks like the data is being saved. To read the data, I do this


[self setDeck: [NSUnarchiver unarchiveObjectWithData: data]];
[cardTableView noteNumberOfRowsChanged];
[self selectCardAtIndex:0];
[noteTextView replaceCharactersInRange:NSMakeRange(0, [[noteTextView textStorage] length]) withRTF:[_deck note]];
[noteTextView scrollRangeToVisible:[noteTextView selectedRange]];

But the noteTextView never updates.

I haven't looked closely at your code, but it looks like you are doing something I recently wrote a class to do, to address similar issues. I just now posted the source code in a file called DIGSTextDisplayState-src.tar at <http://homepage.mac.com/aglee/FileSharing1.html>.

My logic differs slightly from yours in that my class remembers where the text view was scrolled to, which may not be where the selection is. Also, if the text view contained a really tall character (like 96 point) and was scrolled to a point in the middle of that character, my class will restore that exact scroll position if possible. My class is encodable, so you can save it in an NSData like anything else.

I've pasted the readme below. I used to have a demo/test class to show how DIGSTextDisplayState works, but I threw it away. I didn't expect to be posting my code this soon. Anyway, hope it helps.

--Andy

==========
April 12, 2002
Andy Lee (email@hidden)

This directory contains source code for a class called DIGSTextDisplayState. "DIGS" stands for "DigitalSpokes," which is a domain name I own.

A tarball containing this set of files is currently available at <http://homepage.mac.com/aglee/FileSharing1.html>. I am posting this mainly in answer to a question one person asked, but feel free to use it however you like, whoever you are.

I used HeaderDoc <http://www.opensource.apple.com/projects/headerdoc/> to generate HTML docs. Here is an excerpt:

- - - - -
A DIGSTextDisplayState holds a snapshot of the visual state of an NSTextView.

A DIGSTextDisplayState remembers an NSTextView's text, its selection, and the position to which it was scrolled at the moment of the snapshot.

To take a snapshot of an NSTextView, use -rememberDisplayStateOf:. To apply a remembered display state to an NSTextView, use -applyDisplayStateTo:.
- - - - -
_______________________________________________
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: Best way to save this doc?
      • From: Marc Respass <email@hidden>
References: 
 >Best way to save this doc? (From: Marc Respass <email@hidden>)

  • Prev by Date: Using different pictures in an NSRunAlertPanel
  • Next by Date: Re: Java Bridge problem
  • Previous by thread: Best way to save this doc?
  • Next by thread: Re: Best way to save this doc?
  • Index(es):
    • Date
    • Thread