MINoteProtocol

Tags ( )

Inside the MINoteProtocol what's the relationship between:

- (NSString *)noteString;
- (NSData *)noteRTFD;
- (NSTextStorage *)noteTextStorage;

are they used simultaneously or as alternatvies to one another?

Thanks,
Jeff

It's a little tricky. In the

It's a little tricky. In the database Mori saves the note string (so that it can be searched), and it saves the noteRTFD data that stores the note string plus all kinds of extra things like attachments and text attributes. The only reason that a copy of the string is saved separately is for searching purposes.

So the noteString method returns the noteString that's stored in the database. And the noteRTFD metod returns the noteRTFD data that's stored in the database.

And last comes:

- (NSTextStorage *)noteTextStorage;

that returns the "edit buffer" for the note. This might contain the same information that's in the database or it might contain edits of that info that haven't yet been saved to the database.

Hope that helps.

Yes, that

Yes, that helps.
Thanks,
Jeff

Editing an entry's note

Is the proper way to edit an entry's note through its textstorage? I have a NSMutableString *newRecord that I prepend to an entry's note field. Currently I used the code below, but when I "check and repair" the notebook, I often get a repair for a difference between the note string and RFTD string listed in the console. Should I be using a different method to change the note?


DLog(newRecord);
NSTextStorage *newNote;
if (![[[recordToEntry entryData] hasNoteText]boolValue]){
DLog(@"no note");
newNote = [[[NSTextStorage alloc] initWithString:newRecord] autorelease];//autorelease?
}
else {
//[newRecord insertString:[[[recordToEntry entryData] note]noteString] atIndex:0];
newNote = [[[[recordToEntry entryData] note] noteTextStorage] selfAsTextStorage];
[newNote insertAttributedString: [[[NSAttributedString alloc] initWithString:newRecord] autorelease] atIndex:0];
}
[[[recordToEntry entryData] note] setNoteTextStorage: newNote];

Thanks
Jeff

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.