Re: NSTextView
Re: NSTextView
- Subject: Re: NSTextView
- From: albert jordan <email@hidden>
- Date: Wed, 22 Sep 2010 14:56:15 -0700
Thanks Kyle for the suggestion,
I still get the app to hang. if I bypass writing to the text view things work fine, so I'm certain it's this operation that hangs the application. Based on everyone's feedback, below is what I've come up with so far. "adbLog" is the culprit TextView. The app works initially, and I always get the shouldChangeTextInRange method to return YES.
I'm going to try buffering the lines, and update the view in a batch mode... running out of ideas...
Thanks again for all that have helped so far.
Regards,
Albert
BOOL flag = [adbLog shouldChangeTextInRange:NSMakeRange(NSNotFound, 0) replacementString:nil];
if ( flag == YES ) {
NSLog(@"DeviceWindowController: permission to write to buffer\n");
NSMutableAttributedString *attstr = [[[NSMutableAttributedString alloc] initWithString:line] autorelease];
[[adbLog textStorage] beginEditing];
[[adbLog textStorage] appendAttributedString:attstr];
[[adbLog textStorage] endEditing];
[adbLog didChangeText];
//[adbLog display] ;
} else {
NSLog(@"Couldn't get permission to change the text\n");
}
On Sep 22, 2010, at 11:04 AM, Kyle Sluder wrote:
> On Wed, Sep 22, 2010 at 10:43 AM, albert jordan <email@hidden> wrote:
>> Hi Martin,
>>
>> THanks so much for the suggestion.
>>
>> The approach improves the situation, but unfortunately does not resolve it. But understand now that this is the issue, I'm going to see if there will be another work around.
>
> If you want to edit a text view's text storage, you must call
> -shouldChangeTextInRange:replacementString: on the text view before
> mutating the text storage, and then call -didChangeText afterwards.
>
> --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