Re: Document not Saving Text View Attachment
Re: Document not Saving Text View Attachment
- Subject: Re: Document not Saving Text View Attachment
- From: Gordon Apple <email@hidden>
- Date: Sun, 21 Feb 2010 16:00:18 -0600
- Thread-topic: Document not Saving Text View Attachment
This is getting stranger by the minute. I ruled out the menu issue as the
cause, then created a test app from the standard doc template. Window
contain a scrolling text view and a button. The app edits and archives
correctly (compiled using GC). "init" sets an initial string in ts. The
text view is bound to ts.
@interface MyDocument : NSDocument {
IBOutlet NSTextView* tv; // To get caret location.
NSTextStorage* ts;
}
@property(assign) NSTextStorage* ts;
- (IBAction)insertSomething:(id)sender; // Action for button.
@end
- (IBAction)insertSomething:(id)sender {
NSUInteger index = [tv selectedRange].location;
[self.ts beginEditing];
[self.ts insertAttributedString:[[NSAttributedString alloc]
initWithString:@"XYZ"] atIndex:index];
[self.ts endEditing];
}
The latter gets called when the button is pushed and is supposed to insert
"XYZ" at the caret. It all gets called, index is correct, but nada, zilch,
zip. No change. Anything obviously wrong with the above?
On 2/21/10 2:02 PM, "email@hidden"
<email@hidden> wrote:
> On Sat, Feb 20, 2010 at 2:33 PM, Gordon Apple <email@hidden> wrote:
>> Like I said in the post, I tried that. Same result. Just to make sure it
>> had nothing to do with the attachment character, I also tried the following
>> and got the same result:
>
> The point I was making is that you are calling
> -edited:range:changeInLength:, which is a very good sign that you
> aren't completely solid on the (quite convoluted) way in which one
> makes programmatic edits in the text system. NSTextStorage, as a
> subclass of NSMutableAttributedString, calls
> -edited:range:changeInLength: whenever you mutate it with
> -insertAttributedString:... and the like. That in turn calls
> -processEditing.
>
> --Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden