Re: Best way to save this doc?
Re: Best way to save this doc?
- Subject: Re: Best way to save this doc?
- From: Marc Respass <email@hidden>
- Date: Sat, 13 Apr 2002 14:37:00 -0400
Thanks a lot, Andy. Looks like my NIB is corrupted though. I've got
IBOutlet id noteTextView;
and it's bound in my nib but it's never set. I verified by changing the
name in the NIB and I did not get an error saying that the object
couldn't be connected. So, a couple hours of maybe doing the right
thing, maybe not, because my text view wasn't ever connected :\. I'll
see if I can get a text view connected and try your code. Thanks again :)
Marc
On Saturday, April 13, 2002, at 02:17 PM, Andy Lee wrote:
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.
_______________________________________________
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.