Re: Connecting NSTextStorage to a string
Re: Connecting NSTextStorage to a string
- Subject: Re: Connecting NSTextStorage to a string
- From: Keary Suska <email@hidden>
- Date: Fri, 23 Dec 2016 22:08:03 -0700
> On Dec 23, 2016, at 8:16 PM, Daryle Walker <email@hidden> wrote:
>
> The text controls on macOS use a NSTextStorage object to retain their text. That object is a extension of an attributed string. Let's say you use a NSString (or similar) in your document model. How should I get changes on one string to get mirrored on the other?
>
> I think there are begin/end-editing flag methods on text controls, but how would I go the other way?
In my experience, real-time synchronization of vanilla NSString to an NSTextStorage of an NSTextView is painful and fraught with error. Much easier to simply set the content of the NSTextView on load (in windowDidLoad or whatever is apropos for your setup), and then let the NSTextView manage the content until editing has been committed, at which time you pull the plain string out and set your model property.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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