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: Mon, 22 Feb 2010 14:55:11 -0600
- Thread-topic: Document not Saving Text View Attachment
Kyle, thanks for the help. That at least got my test app straightened out.
I have filed Bug ID# 7675789 (with the test app) on the fact that the bound
text does not update from programmatic insertions.
In the test app, I can simply update the bound value myself every time there
is a programmatic update. Unfortunately, that workaround doesn't work in
the actual application because the relevant controller does not have access
to the bound value. I am depending on the binding to properly update the
stored value deep in a data hierarchy.
BTW, in the actual app, the text view is constructed programmatically
because IB has no way to set up an NSTextView outside a scroller. (Some of
us had that discussion here awhile back.) I also had to set the binding
programmatically and set it to continuously update.
On 2/22/10 7:20 AM, "email@hidden"
<email@hidden> wrote:
> Well, I was going to argue with you, but your post triggered further
> investigation. I realized that in the past, I had constructed my own.
> Somehow, in this case, I got it in my head that the bindings would make the
> text view use my NSTextStorage. Duh. So I changed to the following in the
> test app:
>
> @interface MyDocument : NSDocument
> {
> IBOutlet NSTextView* tv;
> NSAttributedString* ts;
> }
> @property(copy) NSAttributedString* ts;
> - (IBAction)insertSomething:(id)sender;
> @end
>
> - (IBAction)insertSomething:(id)sender {
> NSUInteger index = [tv selectedRange].location;
> NSTextStorage* vtc = [tv textStorage];
> [vtc beginEditing];
> [vtc insertAttributedString:[[NSAttributedString alloc]
> initWithString:@"XYZ"] atIndex:index];
> [vtc endEditing];
> }
>
> At least now, I'm dinging the right text storage and the insertion works.
> However, it does confirm my original problem, i.e., that the programmatic
> edit does not show up in the bound NSAttributedString unless there is an
> additional text-entry edit. Now I'm thinking bug report, unless there is
> something else I can do to trigger the KVO for programmatic edits.
>
> I suppose a workaround could be to set up a dummy ivar and a dependency to
> make it update.
>
> On 2/21/10 7:24 PM, "Kyle Sluder" <email@hidden> wrote:
>
>> On Sun, Feb 21, 2010 at 2:00 PM, Gordon Apple <email@hidden> wrote:
>>> 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.
>>
>> You need to post the code that sets up the text system. Unless you
>> actually meant "bound" in the sense of Cocoa Bindings, in which case
>> none of this is ever going to work because then the text view will
>> operate on a copy of the text storage you've provided. The only way to
>> get the text view to use your text storage is to set it up yourself.
>>
>> --Kyle Sluder
--
Gordon Apple
Ed4U
Little Rock, AR
_______________________________________________
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