Best way to save this doc?
Best way to save this doc?
- Subject: Best way to save this doc?
- From: Marc Respass <email@hidden>
- Date: Sat, 13 Apr 2002 12:21:39 -0400
Hi,
I have a document that's working fine but I want to add a text view to
store rich text as a note. It's a Flash Card application. Each document
is a "deck" and each "deck" as an array of "cards". There's a table view
with strings and an NSTextField with a string. This all saves fine if I
just use encodeWithCoder. 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. Running in the debugger, I see the
data is there. Looking through the classes, I can see various ways that
one might get the data and restore it but I don't know for sure which is
best. Maybe my range is no good in the above code? Maybe I should just
use the text view's text storage? That didn't work either
[[noteTextView textStorage] setAttributedString:[_deck note]];
[noteTextView scrollRangeToVisible:[noteTextView selectedRange]];
Any help is appreciated. I'd rather keep using encodeWithCoder into a
flat file rather than make a package with some data and an RTF file
which looks easier but I don't want to use a package for my document
unless there is absolutely no other way.
Thanks
Marc
_______________________________________________
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.